diff --git a/identity-comm/src/lib.rs b/identity-comm/src/lib.rs index ab40abb583..8af2f131fb 100644 --- a/identity-comm/src/lib.rs +++ b/identity-comm/src/lib.rs @@ -17,9 +17,6 @@ // clippy::missing_errors_doc, )] -#[macro_use] -extern crate serde; - pub mod envelope; pub mod error; pub mod message; diff --git a/identity-comm/src/message/macros.rs b/identity-comm/src/message/macros.rs deleted file mode 100644 index 8497a7cc8c..0000000000 --- a/identity-comm/src/message/macros.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2020-2021 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -macro_rules! impl_message_accessor { - ($name:expr, $field:ident => $ty:ty) => { - paste::paste! { - #[doc = "Sets the value of the `"] - #[doc = $name] - #[doc = "` field"] - pub fn []>(&mut self, value: VALUE) { - self.$field = value.into(); - } - - #[doc = "Returns a reference to the `"] - #[doc = $name] - #[doc = "` field"] - pub fn $field(&self) -> &$ty { - &self.$field - } - - #[doc = "Returns a mutable reference to the `"] - #[doc = $name] - #[doc = "` field"] - pub fn [<$field _mut>](&mut self) -> &mut $ty { - &mut self.$field - } - } - }; - ($field:ident => $ty:ty) => { - impl_message_accessor!(stringify!($field), $field => $ty); - }; - ($($field:ident => $ty:ty)+) => { - $( - impl_message_accessor!($field, $ty); - )+ - }; -} diff --git a/identity-comm/src/message/mod.rs b/identity-comm/src/message/mod.rs index 3c9754ea0e..b0bd58710e 100644 --- a/identity-comm/src/message/mod.rs +++ b/identity-comm/src/message/mod.rs @@ -1,15 +1,6 @@ // Copyright 2020-2021 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -#[macro_use] -mod macros; - -mod report; -mod timing; mod traits; -mod types; -pub use self::report::*; -pub use self::timing::*; pub use self::traits::*; -pub use self::types::*; diff --git a/identity-comm/src/message/report.rs b/identity-comm/src/message/report.rs deleted file mode 100644 index fa008dd347..0000000000 --- a/identity-comm/src/message/report.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2020-2021 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 -//! Provides a type for DIDComm problem reports. -use uuid::Uuid; - -use crate::message::Timing; - -/// A loose analogue of [DIDComm problem reports](https://github.com/decentralized-identity/didcomm-messaging/blob/84e5a7c66c87440d39e93df81e4440855273f987/docs/spec-files/problems.md#problem-reports) -#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)] -pub struct Report { - context: String, - thread: Uuid, - reference: String, - #[serde(skip_serializing_if = "Option::is_none")] - error: Option, - #[serde(skip_serializing_if = "Option::is_none")] - comment: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl Report { - /// Creates a new `Report` message. - pub fn new(context: String, thread: Uuid, reference: String) -> Self { - Self { - context, - thread, - reference, - error: None, - comment: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => Uuid); - impl_message_accessor!(reference => String); - impl_message_accessor!(error => Option); - impl_message_accessor!(comment => Option); - impl_message_accessor!(timing => Option); -} diff --git a/identity-comm/src/message/timing.rs b/identity-comm/src/message/timing.rs deleted file mode 100644 index 951074057f..0000000000 --- a/identity-comm/src/message/timing.rs +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2020-2021 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_core::common::Timestamp; - -/// A DIDComm Timing Decorator -/// -/// [Reference](https://github.com/iotaledger/identity.rs/blob/dev/docs/DID%20Communications%20Research%20and%20Specification/Field_Definitions.md) -#[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq)] -pub struct Timing { - #[serde(skip_serializing_if = "Option::is_none")] - out_time: Option, - #[serde(skip_serializing_if = "Option::is_none")] - in_time: Option, - #[serde(skip_serializing_if = "Option::is_none")] - stale_time: Option, - #[serde(skip_serializing_if = "Option::is_none")] - expires_time: Option, - #[serde(skip_serializing_if = "Option::is_none")] - wait_until_time: Option, - #[serde(skip_serializing_if = "Option::is_none")] - delay_milli: Option, -} - -impl Timing { - /// Creates a new `Timing` decorator. - pub fn new() -> Self { - Self { - out_time: None, - in_time: None, - stale_time: None, - expires_time: None, - wait_until_time: None, - delay_milli: None, - } - } - - /// Returns a reference to the `out_time` field. - pub fn out_time(&self) -> Option<&Timestamp> { - self.out_time.as_ref() - } - - /// Returns a mutable reference to the `out_time` field. - pub fn out_time_mut(&mut self) -> Option<&mut Timestamp> { - self.out_time.as_mut() - } - - /// Sets the value of the `out_time` field. - pub fn set_out_time>>(&mut self, value: T) { - self.out_time = value.into(); - } - - /// Returns a reference to the `in_time` field. - pub fn in_time(&self) -> Option<&Timestamp> { - self.in_time.as_ref() - } - - /// Returns a mutable reference to the `in_time` field. - pub fn in_time_mut(&mut self) -> Option<&mut Timestamp> { - self.in_time.as_mut() - } - - /// Sets the value of the `in_time` field. - pub fn set_in_time>>(&mut self, value: T) { - self.in_time = value.into(); - } - - /// Returns a reference to the `stale_time` field. - pub fn stale_time(&self) -> Option<&Timestamp> { - self.stale_time.as_ref() - } - - /// Returns a mutable reference to the `stale_time` field. - pub fn stale_time_mut(&mut self) -> Option<&mut Timestamp> { - self.stale_time.as_mut() - } - - /// Sets the value of the `stale_time` field. - pub fn set_stale_time>>(&mut self, value: T) { - self.stale_time = value.into(); - } - - /// Returns a reference to the `expires_time` field. - pub fn expires_time(&self) -> Option<&Timestamp> { - self.expires_time.as_ref() - } - - /// Returns a mutable reference to the `expires_time` field. - pub fn expires_time_mut(&mut self) -> Option<&mut Timestamp> { - self.expires_time.as_mut() - } - - /// Sets the value of the `expires_time` field. - pub fn set_expires_time>>(&mut self, value: T) { - self.expires_time = value.into(); - } - - /// Returns a reference to the `wait_until_time` field. - pub fn wait_until_time(&self) -> Option<&Timestamp> { - self.wait_until_time.as_ref() - } - - /// Returns a mutable reference to the `wait_until_time` field. - pub fn wait_until_time_mut(&mut self) -> Option<&mut Timestamp> { - self.wait_until_time.as_mut() - } - - /// Sets the value of the `wait_until_time` field. - pub fn set_wait_until_time>>(&mut self, value: T) { - self.wait_until_time = value.into(); - } - - /// Returns the value of the `delay_milli` field. - pub fn delay_milli(&self) -> Option { - self.delay_milli - } - - /// Sets the value of the `delay_milli` field. - pub fn set_delay_milli>>(&mut self, value: T) { - self.delay_milli = value.into(); - } -} diff --git a/identity-comm/src/message/types/authentication.rs b/identity-comm/src/message/types/authentication.rs deleted file mode 100644 index dcce9ac90f..0000000000 --- a/identity-comm/src/message/types/authentication.rs +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2020-2021 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_core::common::Url; -use identity_core::crypto::Signature; -use identity_iota::did::IotaDIDUrl; -use uuid::Uuid; - -use crate::message::Timing; - -/// A DIDComm `authentication` Request. -/// -/// [Reference](https://github.com/iotaledger/identity.rs/blob/dev/docs/DID%20Communications%20Research%20and%20Specification/i_authentication.md#authenticationrequest) -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct AuthenticationRequest { - context: String, - thread: Uuid, - #[serde(rename = "callbackURL")] - callback_url: Url, - challenge: String, - #[serde(rename = "responseRequested", skip_serializing_if = "Option::is_none")] - response_requested: Option, - #[serde(skip_serializing_if = "Option::is_none")] - id: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl AuthenticationRequest { - /// Creates a new `AuthenticationRequest`. - pub fn new(context: String, thread: Uuid, callback_url: Url, challenge: String) -> Self { - Self { - context, - thread, - callback_url, - challenge, - response_requested: None, - id: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => Uuid); - impl_message_accessor!(callback_url => Url); - impl_message_accessor!(challenge => String); - impl_message_accessor!(response_requested => Option); - impl_message_accessor!(id => Option); - impl_message_accessor!(timing => Option); -} - -/// A DIDComm `authentication` Response. -/// -/// [Reference](https://github.com/iotaledger/identity.rs/blob/dev/docs/DID%20Communications%20Research%20and%20Specification/i_authentication.md#authenticationresponse) -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct AuthenticationResponse { - context: String, - thread: Uuid, - signature: Signature, - #[serde(rename = "callbackURL", skip_serializing_if = "Option::is_none")] - callback_url: Option, - #[serde(rename = "responseRequested", skip_serializing_if = "Option::is_none")] - response_requested: Option, - #[serde(skip_serializing_if = "Option::is_none")] - id: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl AuthenticationResponse { - /// Creates a new `AuthenticationResponse`. - pub fn new(context: String, thread: Uuid, signature: Signature) -> Self { - Self { - context, - thread, - signature, - callback_url: None, - response_requested: None, - id: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => Uuid); - impl_message_accessor!(signature => Signature); - impl_message_accessor!(callback_url => Option); - impl_message_accessor!(response_requested => Option); - impl_message_accessor!(id => Option); - impl_message_accessor!(timing => Option); -} diff --git a/identity-comm/src/message/types/credential_issuance.rs b/identity-comm/src/message/types/credential_issuance.rs deleted file mode 100644 index 5116fb6d9a..0000000000 --- a/identity-comm/src/message/types/credential_issuance.rs +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2020-2021 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_core::common::Url; -use identity_iota::did::IotaDIDUrl; -use uuid::Uuid; - -use crate::message::Timing; - -/// A DIDComm `credential-issuance` Request. -/// -/// [Reference](https://github.com/iotaledger/identity.rs/blob/dev/docs/DID%20Communications%20Research%20and%20Specification/i_credential-issuance.md#credentialselection) -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct CredentialSelection { - context: String, - thread: Uuid, - #[serde(rename = "callbackURL")] - callback_url: Url, - #[serde(rename = "credentialTypes")] - credential_types: Vec, - #[serde(rename = "responseRequested", skip_serializing_if = "Option::is_none")] - response_requested: Option, - #[serde(skip_serializing_if = "Option::is_none")] - id: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl CredentialSelection { - /// Creates a new `CredentialSelection`. - pub fn new(context: String, thread: Uuid, callback_url: Url, credential_types: Vec) -> Self { - Self { - context, - thread, - callback_url, - credential_types, - response_requested: None, - id: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => Uuid); - impl_message_accessor!(callback_url => Url); - impl_message_accessor!(credential_types => Vec); - impl_message_accessor!(response_requested => Option); - impl_message_accessor!(id => Option); - impl_message_accessor!(timing => Option); -} - -/// A DIDComm `credential-issuance` Response. -/// -/// [Reference](https://github.com/iotaledger/identity.rs/blob/dev/docs/DID%20Communications%20Research%20and%20Specification/i_credential-issuance.md#credentialissuance) -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct CredentialIssuance { - context: String, - thread: Uuid, - credentials: Vec, - #[serde(rename = "callbackURL", skip_serializing_if = "Option::is_none")] - callback_url: Option, - #[serde(rename = "responseRequested", skip_serializing_if = "Option::is_none")] - response_requested: Option, - #[serde(skip_serializing_if = "Option::is_none")] - id: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl CredentialIssuance { - /// Creates a new `CredentialIssuance`. - pub fn new(context: String, thread: Uuid, credentials: Vec) -> Self { - Self { - context, - thread, - credentials, - callback_url: None, - response_requested: None, - id: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => Uuid); - impl_message_accessor!(credentials => Vec); - impl_message_accessor!(callback_url => Option); - impl_message_accessor!(response_requested => Option); - impl_message_accessor!(id => Option); - impl_message_accessor!(timing => Option); -} diff --git a/identity-comm/src/message/types/credential_options.rs b/identity-comm/src/message/types/credential_options.rs deleted file mode 100644 index 30becc5bf7..0000000000 --- a/identity-comm/src/message/types/credential_options.rs +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2020-2021 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_core::common::Url; -use identity_iota::did::IotaDIDUrl; -use uuid::Uuid; - -use crate::message::Timing; - -/// A DIDComm `credential-options` Request. -/// -/// [Reference](https://github.com/iotaledger/identity.rs/blob/dev/docs/DID%20Communications%20Research%20and%20Specification/i_credential-options.md#credentialoptionsrequest) -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct CredentialOptionRequest { - context: String, - thread: Uuid, - #[serde(rename = "callbackURL")] - callback_url: Url, - #[serde(rename = "responseRequested", skip_serializing_if = "Option::is_none")] - response_requested: Option, - #[serde(skip_serializing_if = "Option::is_none")] - id: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl CredentialOptionRequest { - /// Creates a new `CredentialOptionRequest`. - pub fn new(context: String, thread: Uuid, callback_url: Url) -> Self { - Self { - context, - thread, - callback_url, - response_requested: None, - id: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => Uuid); - impl_message_accessor!(callback_url => Url); - impl_message_accessor!(response_requested => Option); - impl_message_accessor!(id => Option); - impl_message_accessor!(timing => Option); -} - -/// A DIDComm `credential-options` Response. -/// -/// [Reference](https://github.com/iotaledger/identity.rs/blob/dev/docs/DID%20Communications%20Research%20and%20Specification/i_credential-options.md#credentialoptionsresponse) -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct CredentialOptionResponse { - context: String, - thread: Uuid, - #[serde(rename = "credentialTypes")] - credential_types: Vec, - #[serde(rename = "callbackURL", skip_serializing_if = "Option::is_none")] - callback_url: Option, - #[serde(rename = "responseRequested", skip_serializing_if = "Option::is_none")] - response_requested: Option, - #[serde(skip_serializing_if = "Option::is_none")] - id: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl CredentialOptionResponse { - /// Creates a new `CredentialOptionResponse`. - pub fn new(context: String, thread: Uuid, credential_types: Vec) -> Self { - Self { - context, - thread, - credential_types, - callback_url: None, - response_requested: None, - id: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => Uuid); - impl_message_accessor!(credential_types => Vec); - impl_message_accessor!(callback_url => Option); - impl_message_accessor!(response_requested => Option); - impl_message_accessor!(id => Option); - impl_message_accessor!(timing => Option); -} diff --git a/identity-comm/src/message/types/credential_revocation.rs b/identity-comm/src/message/types/credential_revocation.rs deleted file mode 100644 index a45ca19de6..0000000000 --- a/identity-comm/src/message/types/credential_revocation.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2020-2021 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_core::common::Url; -use identity_iota::did::IotaDIDUrl; -use uuid::Uuid; - -use crate::message::Timing; - -/// A DIDComm `credential-revocation` Message -/// -/// [Reference](https://github.com/iotaledger/identity.rs/blob/dev/docs/DID%20Communications%20Research%20and%20Specification/i_credential-revocation.md#revocation) -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct CredentialRevocation { - context: String, - thread: Uuid, - #[serde(rename = "credentialId")] - credential_id: String, - #[serde(rename = "callbackURL", skip_serializing_if = "Option::is_none")] - callback_url: Option, - #[serde(rename = "responseRequested", skip_serializing_if = "Option::is_none")] - response_requested: Option, - #[serde(skip_serializing_if = "Option::is_none")] - id: Option, - #[serde(skip_serializing_if = "Option::is_none")] - comment: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl CredentialRevocation { - /// Creates a new `CredentialRevocation`. - pub fn new(context: String, thread: Uuid, credential_id: String) -> Self { - Self { - context, - thread, - credential_id, - callback_url: None, - response_requested: None, - id: None, - comment: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => Uuid); - impl_message_accessor!(credential_id => String); - impl_message_accessor!(callback_url => Option); - impl_message_accessor!(response_requested => Option); - impl_message_accessor!(id => Option); - impl_message_accessor!(comment => Option); - impl_message_accessor!(timing => Option); -} diff --git a/identity-comm/src/message/types/credential_schema.rs b/identity-comm/src/message/types/credential_schema.rs deleted file mode 100644 index 1326fc9e13..0000000000 --- a/identity-comm/src/message/types/credential_schema.rs +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2020-2021 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_core::common::Url; -use identity_iota::did::IotaDIDUrl; -use uuid::Uuid; - -use crate::message::Timing; - -/// A DIDComm `credential-schema` Request -/// -/// [Reference](https://github.com/iotaledger/identity.rs/blob/dev/docs/DID%20Communications%20Research%20and%20Specification/i_credential-schema.md#credentialschemarequest) -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct CredentialSchemaRequest { - context: String, - thread: Uuid, - #[serde(rename = "callbackURL")] - callback_url: Url, - #[serde(rename = "credentialTypes")] - credential_types: Vec, - #[serde(rename = "responseRequested", skip_serializing_if = "Option::is_none")] - response_requested: Option, - #[serde(skip_serializing_if = "Option::is_none")] - id: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl CredentialSchemaRequest { - /// Creates a new `CredentialSchemaRequest`. - pub fn new(context: String, thread: Uuid, callback_url: Url, credential_types: Vec) -> Self { - Self { - context, - thread, - callback_url, - credential_types, - response_requested: None, - id: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => Uuid); - impl_message_accessor!(callback_url => Url); - impl_message_accessor!(credential_types => Vec); - impl_message_accessor!(response_requested => Option); - impl_message_accessor!(id => Option); - impl_message_accessor!(timing => Option); -} - -/// A DIDComm `credential-schema` Response -/// -/// [Reference](https://github.com/iotaledger/identity.rs/blob/dev/docs/DID%20Communications%20Research%20and%20Specification/i_credential-schema.md#credentialschemaresponse) -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct CredentialSchemaResponse { - context: String, - thread: String, - schemata: Vec, - #[serde(rename = "callbackURL", skip_serializing_if = "Option::is_none")] - callback_url: Option, - #[serde(rename = "responseRequested", skip_serializing_if = "Option::is_none")] - response_requested: Option, - #[serde(skip_serializing_if = "Option::is_none")] - id: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl CredentialSchemaResponse { - /// Creates a new `CredentialSchemaResponse`. - pub fn new(context: String, thread: String, schemata: Vec, callback_url: Option) -> Self { - Self { - context, - thread, - schemata, - callback_url, - response_requested: None, - id: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => String); - impl_message_accessor!(schemata => Vec); - impl_message_accessor!(callback_url => Option); - impl_message_accessor!(response_requested => Option); - impl_message_accessor!(id => Option); - impl_message_accessor!(timing => Option); -} diff --git a/identity-comm/src/message/types/did_discovery.rs b/identity-comm/src/message/types/did_discovery.rs deleted file mode 100644 index 4e2899c468..0000000000 --- a/identity-comm/src/message/types/did_discovery.rs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2020-2021 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_core::common::Url; -use identity_iota::did::IotaDIDUrl; -use uuid::Uuid; - -use crate::message::Timing; - -/// A DIDComm `did-discovery` Request. -/// -/// [Reference](https://github.com/iotaledger/identity.rs/blob/dev/docs/DID%20Communications%20Research%20and%20Specification/i_did-discovery.md#didrequest) -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct DidRequest { - context: String, - thread: Uuid, - #[serde(rename = "callbackURL")] - callback_url: Url, - #[serde(rename = "responseRequested", skip_serializing_if = "Option::is_none")] - response_requested: Option, - #[serde(skip_serializing_if = "Option::is_none")] - id: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl DidRequest { - /// Creates a new `DidRequest`. - pub fn new(context: String, thread: Uuid, callback_url: Url) -> Self { - Self { - context, - thread, - callback_url, - response_requested: None, - id: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => Uuid); - impl_message_accessor!(callback_url => Url); - impl_message_accessor!(response_requested => Option); - impl_message_accessor!(id => Option); - impl_message_accessor!(timing => Option); -} - -/// A DIDComm `did-discovery` Response. -/// -/// [Reference](https://github.com/iotaledger/identity.rs/blob/dev/docs/DID%20Communications%20Research%20and%20Specification/i_did-discovery.md#didresponse) -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct DidResponse { - context: String, - thread: Uuid, - id: IotaDIDUrl, - #[serde(rename = "callbackURL", skip_serializing_if = "Option::is_none")] - callback_url: Option, - #[serde(rename = "responseRequested", skip_serializing_if = "Option::is_none")] - response_requested: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl DidResponse { - /// Creates a new `DidResponse`. - pub fn new(context: String, thread: Uuid, id: IotaDIDUrl) -> Self { - Self { - context, - thread, - id, - callback_url: None, - response_requested: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => Uuid); - impl_message_accessor!(id => IotaDIDUrl); - impl_message_accessor!(callback_url => Option); - impl_message_accessor!(response_requested => Option); - impl_message_accessor!(timing => Option); -} diff --git a/identity-comm/src/message/types/did_introduction.rs b/identity-comm/src/message/types/did_introduction.rs deleted file mode 100644 index 2982321757..0000000000 --- a/identity-comm/src/message/types/did_introduction.rs +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright 2020-2021 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_core::common::Url; -use identity_iota::did::IotaDIDUrl; -use uuid::Uuid; - -use crate::message::Timing; - -/// A DIDComm `did-introduction` Request. -/// -/// [Reference](https://github.com/iotaledger/identity.rs/blob/dev/docs/DID%20Communications%20Research%20and%20Specification/i_did-introduction.md#introductionproposal) -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct IntroductionProposal { - context: String, - thread: Uuid, - #[serde(rename = "callbackURL")] - callback_url: Url, - #[serde(rename = "responseRequested", skip_serializing_if = "Option::is_none")] - response_requested: Option, - #[serde(skip_serializing_if = "Option::is_none")] - id: Option, - #[serde(skip_serializing_if = "Option::is_none")] - comment: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl IntroductionProposal { - /// Creates a new `IntroductionProposal`. - pub fn new(context: String, thread: Uuid, callback_url: Url) -> Self { - Self { - context, - thread, - callback_url, - response_requested: None, - id: None, - comment: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => Uuid); - impl_message_accessor!(callback_url => Url); - impl_message_accessor!(response_requested => Option); - impl_message_accessor!(id => Option); - impl_message_accessor!(comment => Option); - impl_message_accessor!(timing => Option); -} - -/// A DIDComm `did-introduction` Response. -/// -/// [Reference](https://github.com/iotaledger/identity.rs/blob/dev/docs/DID%20Communications%20Research%20and%20Specification/i_did-introduction.md#introductionresponse) -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct IntroductionResponse { - context: String, - thread: Uuid, - consent: bool, - #[serde(rename = "callbackURL", skip_serializing_if = "Option::is_none")] - callback_url: Option, - #[serde(rename = "responseRequested", skip_serializing_if = "Option::is_none")] - response_requested: Option, - #[serde(skip_serializing_if = "Option::is_none")] - id: Option, - #[serde(skip_serializing_if = "Option::is_none")] - comment: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl IntroductionResponse { - /// Creates a new `IntroductionResponse`. - pub fn new(context: String, thread: Uuid, consent: bool) -> Self { - Self { - context, - thread, - consent, - callback_url: None, - response_requested: None, - id: None, - comment: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => Uuid); - impl_message_accessor!(consent => bool); - impl_message_accessor!(callback_url => Option); - impl_message_accessor!(response_requested => Option); - impl_message_accessor!(id => Option); - impl_message_accessor!(comment => Option); - impl_message_accessor!(timing => Option); -} - -/// A DIDComm `introduction` Message -/// -/// [Reference](https://github.com/iotaledger/identity.rs/blob/dev/docs/DID%20Communications%20Research%20and%20Specification/i_did-introduction.md#introduction) -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct Introduction { - context: String, - thread: Uuid, - ids: Vec, - #[serde(rename = "callbackURL", skip_serializing_if = "Option::is_none")] - callback_url: Option, - #[serde(rename = "responseRequested", skip_serializing_if = "Option::is_none")] - response_requested: Option, - #[serde(skip_serializing_if = "Option::is_none")] - id: Option, - #[serde(skip_serializing_if = "Option::is_none")] - comment: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl Introduction { - /// Creates a new `Introduction`. - pub fn new(context: String, thread: Uuid, ids: Vec) -> Self { - Self { - context, - thread, - ids, - callback_url: None, - response_requested: None, - id: None, - comment: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => Uuid); - impl_message_accessor!(ids => Vec); - impl_message_accessor!(callback_url => Option); - impl_message_accessor!(response_requested => Option); - impl_message_accessor!(id => Option); - impl_message_accessor!(comment => Option); - impl_message_accessor!(timing => Option); -} diff --git a/identity-comm/src/message/types/did_resolution.rs b/identity-comm/src/message/types/did_resolution.rs deleted file mode 100644 index 6cc9f7f788..0000000000 --- a/identity-comm/src/message/types/did_resolution.rs +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2020-2021 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_core::common::Url; -use identity_iota::did::IotaDIDUrl; -use identity_iota::did::IotaDocument; -use uuid::Uuid; - -use crate::message::Timing; - -/// A DIDComm `did-resolution` Request. -/// -/// [Reference](https://github.com/iotaledger/identity.rs/blob/dev/docs/DID%20Communications%20Research%20and%20Specification/i_did-resolution.md#resolutionrequest) -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct ResolutionRequest { - context: String, - thread: Uuid, - #[serde(rename = "callbackURL")] - callback_url: Url, - #[serde(rename = "responseRequested", skip_serializing_if = "Option::is_none")] - response_requested: Option, - #[serde(skip_serializing_if = "Option::is_none")] - id: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl ResolutionRequest { - /// Creates a new `ResolutionRequest` - pub fn new(context: String, thread: Uuid, callback_url: Url) -> Self { - Self { - context, - thread, - callback_url, - response_requested: None, - id: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => Uuid); - impl_message_accessor!(callback_url => Url); - impl_message_accessor!(response_requested => Option); - impl_message_accessor!(id => Option); - impl_message_accessor!(timing => Option); -} - -/// A DIDComm `did-resolution` Response. -/// -/// [Reference](https://github.com/iotaledger/identity.rs/blob/dev/docs/DID%20Communications%20Research%20and%20Specification/i_did-resolution.md#resolutionresponse) -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct ResolutionResponse { - context: String, - thread: Uuid, - #[serde(rename = "didDocument")] - did_document: IotaDocument, - #[serde(rename = "callbackURL", skip_serializing_if = "Option::is_none")] - callback_url: Option, - #[serde(rename = "responseRequested", skip_serializing_if = "Option::is_none")] - response_requested: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl ResolutionResponse { - /// Creates a new `ResolutionResponse` - pub fn new(context: String, thread: Uuid, did_document: IotaDocument) -> Self { - Self { - context, - thread, - did_document, - callback_url: None, - response_requested: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => Uuid); - impl_message_accessor!(did_document => IotaDocument); - impl_message_accessor!(callback_url => Option); - impl_message_accessor!(response_requested => Option); - impl_message_accessor!(timing => Option); -} diff --git a/identity-comm/src/message/types/features_discovery.rs b/identity-comm/src/message/types/features_discovery.rs deleted file mode 100644 index 2f41c544fc..0000000000 --- a/identity-comm/src/message/types/features_discovery.rs +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2020-2021 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 -//! Provides types loosely representing the request and response roles from the [Discover Features Protocol](https://github.com/decentralized-identity/didcomm-messaging/blob/84e5a7c66c87440d39e93df81e4440855273f987/docs/spec-files/feature_discovery.md#discover-features-protocol-10) - -use identity_core::common::Url; -use identity_iota::did::IotaDIDUrl; -use uuid::Uuid; - -use crate::message::Timing; - -/// Analogue of a [DIDComm `features-discovery` Request](https://github.com/decentralized-identity/didcomm-messaging/blob/84e5a7c66c87440d39e93df81e4440855273f987/docs/spec-files/feature_discovery.md#discover-features-protocol-10) -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct FeaturesRequest { - context: String, - thread: Uuid, - #[serde(rename = "callbackURL")] - callback_url: Url, - #[serde(rename = "responseRequested", skip_serializing_if = "Option::is_none")] - response_requested: Option, - #[serde(skip_serializing_if = "Option::is_none")] - id: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl FeaturesRequest { - /// Creates a new `FeaturesRequest`. - pub fn new(context: String, thread: Uuid, callback_url: Url) -> Self { - Self { - context, - thread, - callback_url, - response_requested: None, - id: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => Uuid); - impl_message_accessor!(callback_url => Url); - impl_message_accessor!(response_requested => Option); - impl_message_accessor!(id => Option); - impl_message_accessor!(timing => Option); -} - -/// Analogue of a [DIDComm `features-discovery` Response](https://github.com/decentralized-identity/didcomm-messaging/blob/84e5a7c66c87440d39e93df81e4440855273f987/docs/spec-files/feature_discovery.md#discover-features-protocol-10) -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct FeaturesResponse { - context: String, - thread: Uuid, - features: Vec, - #[serde(rename = "callbackURL", skip_serializing_if = "Option::is_none")] - callback_url: Option, - #[serde(rename = "responseRequested", skip_serializing_if = "Option::is_none")] - response_requested: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl FeaturesResponse { - /// Creates a new `FeaturesResponse`. - pub fn new(context: String, thread: Uuid, features: Vec) -> Self { - Self { - context, - thread, - features, - callback_url: None, - response_requested: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => Uuid); - impl_message_accessor!(features => Vec); - impl_message_accessor!(callback_url => Option); - impl_message_accessor!(response_requested => Option); - impl_message_accessor!(timing => Option); -} diff --git a/identity-comm/src/message/types/mod.rs b/identity-comm/src/message/types/mod.rs deleted file mode 100644 index ed0ceec20c..0000000000 --- a/identity-comm/src/message/types/mod.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2020-2021 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 -//! Provides types for various DIDComm protocols. - -mod authentication; -mod credential_issuance; -mod credential_options; -mod credential_revocation; -mod credential_schema; -mod did_discovery; -mod did_introduction; -mod did_resolution; -mod features_discovery; -mod presentation_verification; -mod trust_ping; - -pub use self::authentication::*; -pub use self::credential_issuance::*; -pub use self::credential_options::*; -pub use self::credential_revocation::*; -pub use self::credential_schema::*; -pub use self::did_discovery::*; -pub use self::did_introduction::*; -pub use self::did_resolution::*; -pub use self::features_discovery::*; -pub use self::presentation_verification::*; -pub use self::trust_ping::*; diff --git a/identity-comm/src/message/types/presentation_verification.rs b/identity-comm/src/message/types/presentation_verification.rs deleted file mode 100644 index 4cf2b36118..0000000000 --- a/identity-comm/src/message/types/presentation_verification.rs +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright 2020-2021 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_core::common::Url; -use identity_credential::presentation::Presentation; -use identity_iota::did::IotaDIDUrl; -use uuid::Uuid; - -use crate::message::Timing; - -/// A DIDComm `presentation-verification` Request. -/// -/// [Reference](https://github.com/iotaledger/identity.rs/blob/dev/docs/DID%20Communications%20Research%20and%20Specification/i_presentation-verification.md#presentationrequest) -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct PresentationRequest { - context: String, - thread: Uuid, - #[serde(rename = "callbackURL")] - callback_url: Url, - #[serde(rename = "trustedIssuers", skip_serializing_if = "Option::is_none")] - trusted_issuers: Option>, - #[serde(rename = "responseRequested", skip_serializing_if = "Option::is_none")] - response_requested: Option, - #[serde(skip_serializing_if = "Option::is_none")] - id: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl PresentationRequest { - /// Creates a new `PresentationRequest`. - pub fn new(context: String, thread: Uuid, callback_url: Url) -> Self { - Self { - context, - thread, - callback_url, - trusted_issuers: None, - response_requested: None, - id: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => Uuid); - impl_message_accessor!(callback_url => Url); - impl_message_accessor!(trusted_issuers => Option>); - impl_message_accessor!(response_requested => Option); - impl_message_accessor!(id => Option); - impl_message_accessor!(timing => Option); -} - -/// A DIDComm `presentation-verification` Response. -/// -/// [Reference](https://github.com/iotaledger/identity.rs/blob/dev/docs/DID%20Communications%20Research%20and%20Specification/i_presentation-verification.md#presentationresponse) -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct PresentationResponse { - context: String, - thread: Uuid, - #[serde(rename = "verifiablePresentation")] - verifiable_presentation: Presentation, - #[serde(rename = "callbackURL", skip_serializing_if = "Option::is_none")] - callback_url: Option, - #[serde(rename = "responseRequested", skip_serializing_if = "Option::is_none")] - response_requested: Option, - #[serde(skip_serializing_if = "Option::is_none")] - id: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl PresentationResponse { - /// Creates a new `PresentationResponse`. - pub fn new(context: String, thread: Uuid, verifiable_presentation: Presentation) -> Self { - Self { - context, - thread, - verifiable_presentation, - callback_url: None, - response_requested: None, - id: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => Uuid); - impl_message_accessor!(verifiable_presentation => Presentation); - impl_message_accessor!(callback_url => Option); - impl_message_accessor!(response_requested => Option); - impl_message_accessor!(id => Option); - impl_message_accessor!(timing => Option); -} - -#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)] -pub struct TrustedIssuer { - #[serde(rename = "credentialTypes")] - credential_types: Vec, - #[serde(rename = "supportedIssuers")] - supported_issuers: Vec, -} - -impl TrustedIssuer { - /// Creates a new `TrustedIssuer`. - pub fn new() -> Self { - Self { - credential_types: Vec::new(), - supported_issuers: Vec::new(), - } - } - - impl_message_accessor!(credential_types => Vec); - impl_message_accessor!(supported_issuers => Vec); -} diff --git a/identity-comm/src/message/types/trust_ping.rs b/identity-comm/src/message/types/trust_ping.rs deleted file mode 100644 index cac74aa9fc..0000000000 --- a/identity-comm/src/message/types/trust_ping.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2020-2021 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 -//! Provides a type used in a `ping message` from the [Trust-Ping Protocol](https://github.com/decentralized-identity/didcomm-messaging/blob/84e5a7c66c87440d39e93df81e4440855273f987/docs/spec-files/trustping.md) - -use identity_core::common::Url; -use identity_iota::did::IotaDIDUrl; -use uuid::Uuid; - -use crate::message::Timing; - -/// A DIDComm `trust-ping` Message. -/// -/// [Reference](https://github.com/decentralized-identity/didcomm-messaging/blob/84e5a7c66c87440d39e93df81e4440855273f987/docs/spec-files/trustping.md) -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct TrustPing { - context: String, - #[serde(skip_serializing_if = "Option::is_none")] - thread: Option, - #[serde(rename = "callbackURL", skip_serializing_if = "Option::is_none")] - callback_url: Option, - #[serde(rename = "responseRequested", skip_serializing_if = "Option::is_none")] - response_requested: Option, - #[serde(skip_serializing_if = "Option::is_none")] - id: Option, - #[serde(skip_serializing_if = "Option::is_none")] - timing: Option, -} - -impl TrustPing { - /// Creates a new `TrustPing`. - pub fn new(context: String) -> Self { - Self { - context, - thread: None, - callback_url: None, - response_requested: None, - id: None, - timing: None, - } - } - - impl_message_accessor!(context => String); - impl_message_accessor!(thread => Option); - impl_message_accessor!(callback_url => Option); - impl_message_accessor!(response_requested => Option); - impl_message_accessor!(id => Option); - impl_message_accessor!(timing => Option); -} diff --git a/identity-comm/tests/message_authentication.rs b/identity-comm/tests/message_authentication.rs deleted file mode 100644 index 3242ebf96f..0000000000 --- a/identity-comm/tests/message_authentication.rs +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2020-2021 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// use core::slice; -// use identity_core::crypto::KeyPair; -// use identity_core::crypto::PublicKey; -// use identity_core::crypto::PrivateKey; -// use libjose::utils::ed25519_to_x25519_public; -// use libjose::utils::ed25519_to_x25519_secret; - -// use super::*; -// use crate::envelope::Encrypted; -// use crate::envelope::EncryptionAlgorithm; -// use crate::envelope::SignatureAlgorithm; -// use crate::error::Result; -// use crate::message::Message; - -// #[test] -// fn test_plaintext_roundtrip() { -// let authentication_request = AuthenticationRequest::new( -// "authentication/1.0/authenticationRequest".to_string(), -// Uuid::new_v4(), -// Url::parse("htpps://example.com").unwrap(), -// "please sign this".to_string(), -// ); -// let plain_envelope_request = authentication_request.pack_plain().unwrap(); -// let request: AuthenticationRequest = plain_envelope_request.unpack().unwrap(); -// assert_eq!(format!("{:?}", request), format!("{:?}", authentication_request)); -// } - -// #[test] -// fn test_signed_roundtrip() { -// let keypair = KeyPair::new_ed25519().unwrap(); - -// let authentication_request = AuthenticationRequest::new( -// "authentication/1.0/authenticationRequest".to_string(), -// Uuid::new_v4(), -// Url::parse("htpps://example.com").unwrap(), -// "please sign this".to_string(), -// ); -// let signed_request = authentication_request -// .pack_non_repudiable(SignatureAlgorithm::EdDSA, &keypair) -// .unwrap(); - -// let request = signed_request -// .unpack::(SignatureAlgorithm::EdDSA, &keypair.public()) -// .unwrap(); - -// assert_eq!(format!("{:?}", request), format!("{:?}", authentication_request)); -// } - -// fn ed25519_to_x25519(keypair: KeyPair) -> Result<(PublicKey, PrivateKey)> { -// Ok(( -// ed25519_to_x25519_public(keypair.public())?.to_vec().into(), -// ed25519_to_x25519_secret(keypair.secret())?.to_vec().into(), -// )) -// } - -// fn ed25519_to_x25519_keypair(keypair: KeyPair) -> Result { -// // This is completely wrong but `type_` is never used around here -// let type_ = keypair.type_(); -// let (public, secret) = ed25519_to_x25519(keypair)?; -// Ok((type_, public, secret).into()) -// } - -// #[test] -// fn test_encrypted_roundtrip() { -// let key_alice = KeyPair::new_ed25519().unwrap(); -// let key_alice = ed25519_to_x25519_keypair(key_alice).unwrap(); - -// let key_bob = KeyPair::new_ed25519().unwrap(); -// let key_bob = ed25519_to_x25519_keypair(key_bob).unwrap(); - -// let authentication_request = AuthenticationRequest::new( -// "authentication/1.0/authenticationRequest".to_string(), -// Uuid::new_v4(), -// Url::parse("htpps://example.com").unwrap(), -// "please sign this".to_string(), -// ); -// let recipients = slice::from_ref(key_alice.public()); - -// let encoded_request: Encrypted = authentication_request -// .pack_auth(EncryptionAlgorithm::A256GCM, recipients, &key_bob) -// .unwrap(); - -// let decoded_request: AuthenticationRequest = encoded_request -// .unpack(EncryptionAlgorithm::A256GCM, key_alice.secret(), key_bob.public()) -// .unwrap(); - -// assert_eq!( -// format!("{:?}", decoded_request), -// format!("{:?}", authentication_request) -// ); -// } diff --git a/identity-comm/tests/message_did_resolution.rs b/identity-comm/tests/message_did_resolution.rs deleted file mode 100644 index 9d4f56317d..0000000000 --- a/identity-comm/tests/message_did_resolution.rs +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2020-2021 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// use core::slice; -// use identity_core::crypto::KeyPair; -// use identity_core::crypto::PublicKey; -// use identity_core::crypto::PrivateKey; -// use libjose::utils::ed25519_to_x25519_public; -// use libjose::utils::ed25519_to_x25519_secret; - -// use super::*; -// use crate::envelope::Encrypted; -// use crate::envelope::EncryptionAlgorithm; -// use crate::envelope::SignatureAlgorithm; -// use crate::error::Result; -// use crate::message::Message; - -// #[test] -// fn test_plaintext_roundtrip() { -// let keypair = KeyPair::new_ed25519().unwrap(); -// let resolution_request = ResolutionRequest::new( -// "did-discovery/1.0/did-resolution/1.0/resolutionRequest".to_string(), -// Uuid::new_v4(), -// Url::parse("https://example.com").unwrap(), -// ); -// let resolotion_respone = ResolutionResponse::new( -// "did-resolution/1.0/resolutionResponse".to_string(), -// Uuid::new_v4(), -// Document::from_keypair(&keypair).unwrap(), -// ); - -// let plain_envelope_request = resolution_request.pack_plain().unwrap(); -// let plain_envelope_response = resolotion_respone.pack_plain().unwrap(); - -// let request: ResolutionRequest = plain_envelope_request.unpack().unwrap(); -// let response: ResolutionResponse = plain_envelope_response.unpack().unwrap(); -// assert_eq!(format!("{:?}", request), format!("{:?}", resolution_request)); -// assert_eq!(format!("{:?}", response), format!("{:?}", resolotion_respone)); -// } - -// #[test] -// fn test_signed_roundtrip() { -// let keypair = KeyPair::new_ed25519().unwrap(); - -// let resolution_request = ResolutionRequest::new( -// "did-discovery/1.0/did-resolution/1.0/resolutionRequest".to_string(), -// Uuid::new_v4(), -// Url::parse("https://example.com").unwrap(), -// ); -// let resolotion_respone = ResolutionResponse::new( -// "did-resolution/1.0/resolutionResponse".to_string(), -// Uuid::new_v4(), -// Document::from_keypair(&keypair).unwrap(), -// ); -// let signed_envelope_request = resolution_request -// .pack_non_repudiable(SignatureAlgorithm::EdDSA, &keypair) -// .unwrap(); - -// let signed_envelope_response = resolotion_respone -// .pack_non_repudiable(SignatureAlgorithm::EdDSA, &keypair) -// .unwrap(); - -// let request = signed_envelope_request -// .unpack::(SignatureAlgorithm::EdDSA, &keypair.public()) -// .unwrap(); - -// let response = signed_envelope_response -// .unpack::(SignatureAlgorithm::EdDSA, &keypair.public()) -// .unwrap(); - -// assert_eq!(format!("{:?}", request), format!("{:?}", resolution_request)); -// assert_eq!(format!("{:?}", response), format!("{:?}", resolotion_respone)); -// } - -// fn ed25519_to_x25519(keypair: KeyPair) -> Result<(PublicKey, PrivateKey)> { -// Ok(( -// ed25519_to_x25519_public(keypair.public())?.to_vec().into(), -// ed25519_to_x25519_secret(keypair.secret())?.to_vec().into(), -// )) -// } - -// fn ed25519_to_x25519_keypair(keypair: KeyPair) -> Result { -// // This is completely wrong but `type_` is never used around here -// let type_ = keypair.type_(); -// let (public, secret) = ed25519_to_x25519(keypair)?; -// Ok((type_, public, secret).into()) -// } - -// #[test] -// fn test_encrypted_roundtrip() { -// let keypair = KeyPair::new_ed25519().unwrap(); -// let key_alice = KeyPair::new_ed25519().unwrap(); -// let key_alice = ed25519_to_x25519_keypair(key_alice).unwrap(); - -// let key_bob = KeyPair::new_ed25519().unwrap(); -// let key_bob = ed25519_to_x25519_keypair(key_bob).unwrap(); - -// let resolution_request = ResolutionRequest::new( -// "did-discovery/1.0/did-resolution/1.0/resolutionRequest".to_string(), -// Uuid::new_v4(), -// Url::parse("https://example.com").unwrap(), -// ); -// let resolotion_respone = ResolutionResponse::new( -// "did-resolution/1.0/resolutionResponse".to_string(), -// Uuid::new_v4(), -// Document::from_keypair(&keypair).unwrap(), -// ); - -// let recipients = slice::from_ref(key_alice.public()); - -// let encrypted_envelope_request: Encrypted = resolution_request -// .pack_auth(EncryptionAlgorithm::A256GCM, recipients, &key_bob) -// .unwrap(); - -// let encrypted_envelope_response: Encrypted = resolotion_respone -// .pack_auth(EncryptionAlgorithm::A256GCM, recipients, &key_bob) -// .unwrap(); - -// let request: ResolutionRequest = encrypted_envelope_request -// .unpack(EncryptionAlgorithm::A256GCM, key_alice.secret(), key_bob.public()) -// .unwrap(); - -// let response: ResolutionResponse = encrypted_envelope_response -// .unpack(EncryptionAlgorithm::A256GCM, key_alice.secret(), key_bob.public()) -// .unwrap(); - -// assert_eq!(format!("{:?}", request), format!("{:?}", resolution_request)); -// assert_eq!(format!("{:?}", response), format!("{:?}", resolotion_respone)); -// } diff --git a/identity-comm/tests/message_features_discovery.rs b/identity-comm/tests/message_features_discovery.rs deleted file mode 100644 index ab85802ba0..0000000000 --- a/identity-comm/tests/message_features_discovery.rs +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright 2020-2021 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// use core::slice; -// use identity_core::crypto::KeyPair; -// use identity_core::crypto::PublicKey; -// use identity_core::crypto::PrivateKey; -// use libjose::utils::ed25519_to_x25519_public; -// use libjose::utils::ed25519_to_x25519_secret; - -// use super::*; -// use crate::envelope::Encrypted; -// use crate::envelope::EncryptionAlgorithm; -// use crate::envelope::SignatureAlgorithm; -// use crate::error::Result; -// use crate::message::Message; - -// #[test] -// fn test_plaintext_roundtrip() { -// let did_request = FeaturesRequest::new( -// "did-discovery/1.0/didRequest".to_string(), -// Uuid::new_v4(), -// Url::parse("https://example.com").unwrap(), -// ); -// let did_response = FeaturesResponse::new( -// "did-discovery/1.0/didResponse".to_string(), -// Uuid::new_v4(), -// vec!["trust-ping/1.0".to_string(), "did-discovery/1.0".to_string()], -// ); - -// let plain_envelope_request = did_request.pack_plain().unwrap(); -// let plain_envelope_response = did_response.pack_plain().unwrap(); - -// let request: FeaturesRequest = plain_envelope_request.unpack().unwrap(); -// let response: FeaturesResponse = plain_envelope_response.unpack().unwrap(); - -// assert_eq!(format!("{:?}", request), format!("{:?}", did_request)); -// assert_eq!(format!("{:?}", response), format!("{:?}", did_response)); -// } - -// #[test] -// fn test_signed_roundtrip() { -// let keypair = KeyPair::new_ed25519().unwrap(); - -// let did_request = FeaturesRequest::new( -// "did-discovery/1.0/didRequest".to_string(), -// Uuid::new_v4(), -// Url::parse("https://example.com").unwrap(), -// ); -// let did_response = FeaturesResponse::new( -// "did-discovery/1.0/didResponse".to_string(), -// Uuid::new_v4(), -// vec!["trust-ping/1.0".to_string(), "did-discovery/1.0".to_string()], -// ); -// let signed_request = did_request -// .pack_non_repudiable(SignatureAlgorithm::EdDSA, &keypair) -// .unwrap(); - -// let signed_response = did_response -// .pack_non_repudiable(SignatureAlgorithm::EdDSA, &keypair) -// .unwrap(); - -// let request = signed_request -// .unpack::(SignatureAlgorithm::EdDSA, &keypair.public()) -// .unwrap(); - -// let response = signed_response -// .unpack::(SignatureAlgorithm::EdDSA, &keypair.public()) -// .unwrap(); - -// assert_eq!(format!("{:?}", request), format!("{:?}", did_request)); -// assert_eq!(format!("{:?}", response), format!("{:?}", did_response)); -// } - -// fn ed25519_to_x25519(keypair: KeyPair) -> Result<(PublicKey, PrivateKey)> { -// Ok(( -// ed25519_to_x25519_public(keypair.public())?.to_vec().into(), -// ed25519_to_x25519_secret(keypair.secret())?.to_vec().into(), -// )) -// } - -// fn ed25519_to_x25519_keypair(keypair: KeyPair) -> Result { -// // This is completely wrong but `type_` is never used around here -// let type_ = keypair.type_(); -// let (public, secret) = ed25519_to_x25519(keypair)?; -// Ok((type_, public, secret).into()) -// } - -// #[test] -// fn test_encrypted_roundtrip() { -// let key_alice = KeyPair::new_ed25519().unwrap(); -// let key_alice = ed25519_to_x25519_keypair(key_alice).unwrap(); - -// let key_bob = KeyPair::new_ed25519().unwrap(); -// let key_bob = ed25519_to_x25519_keypair(key_bob).unwrap(); - -// let did_request = FeaturesRequest::new( -// "did-discovery/1.0/didRequest".to_string(), -// Uuid::new_v4(), -// Url::parse("https://example.com").unwrap(), -// ); -// let did_response = FeaturesResponse::new( -// "did-discovery/1.0/didResponse".to_string(), -// Uuid::new_v4(), -// vec!["trust-ping/1.0".to_string(), "did-discovery/1.0".to_string()], -// ); -// let recipients = slice::from_ref(key_alice.public()); - -// let encoded_request: Encrypted = did_request -// .pack_auth(EncryptionAlgorithm::A256GCM, recipients, &key_bob) -// .unwrap(); - -// let encoded_response: Encrypted = did_response -// .pack_auth(EncryptionAlgorithm::A256GCM, recipients, &key_bob) -// .unwrap(); - -// let decoded_request: FeaturesRequest = encoded_request -// .unpack(EncryptionAlgorithm::A256GCM, key_alice.secret(), key_bob.public()) -// .unwrap(); - -// let decoded_response: FeaturesResponse = encoded_response -// .unpack(EncryptionAlgorithm::A256GCM, key_alice.secret(), key_bob.public()) -// .unwrap(); - -// assert_eq!(format!("{:?}", decoded_request), format!("{:?}", did_request)); -// assert_eq!(format!("{:?}", decoded_response), format!("{:?}", did_response)); -// } diff --git a/identity-comm/tests/message_trust_ping.rs b/identity-comm/tests/message_trust_ping.rs deleted file mode 100644 index c308937561..0000000000 --- a/identity-comm/tests/message_trust_ping.rs +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2020-2021 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// use core::slice; -// use identity_core::crypto::KeyPair; -// use identity_core::crypto::PublicKey; -// use identity_core::crypto::PrivateKey; -// use libjose::utils::ed25519_to_x25519_public; -// use libjose::utils::ed25519_to_x25519_secret; - -// use super::*; -// use crate::envelope::Encrypted; -// use crate::envelope::EncryptionAlgorithm; -// use crate::envelope::SignatureAlgorithm; -// use crate::error::Result; -// use crate::message::Message; - -// #[test] -// fn test_plaintext_roundtrip() { -// let ping = TrustPing::new("trust-ping/1.0/ping".to_string()); - -// let plain_envelope_ping = ping.pack_plain().unwrap(); - -// let tp: TrustPing = plain_envelope_ping.unpack().unwrap(); - -// assert_eq!(format!("{:?}", tp), format!("{:?}", ping)); -// } - -// #[test] -// fn test_signed_roundtrip() { -// let keypair = KeyPair::new_ed25519().unwrap(); - -// let ping = TrustPing::new("trust-ping/1.0/ping".to_string()); - -// let signed_envelope_ping = ping.pack_non_repudiable(SignatureAlgorithm::EdDSA, &keypair).unwrap(); - -// let tp = signed_envelope_ping -// .unpack::(SignatureAlgorithm::EdDSA, &keypair.public()) -// .unwrap(); - -// assert_eq!(format!("{:?}", tp), format!("{:?}", ping)); -// } - -// fn ed25519_to_x25519(keypair: KeyPair) -> Result<(PublicKey, PrivateKey)> { -// Ok(( -// ed25519_to_x25519_public(keypair.public())?.to_vec().into(), -// ed25519_to_x25519_secret(keypair.secret())?.to_vec().into(), -// )) -// } - -// fn ed25519_to_x25519_keypair(keypair: KeyPair) -> Result { -// // This is completely wrong but `type_` is never used around here -// let type_ = keypair.type_(); -// let (public, secret) = ed25519_to_x25519(keypair)?; -// Ok((type_, public, secret).into()) -// } - -// #[test] -// fn test_encrypted_roundtrip() { -// let key_alice = KeyPair::new_ed25519().unwrap(); -// let key_alice = ed25519_to_x25519_keypair(key_alice).unwrap(); - -// let key_bob = KeyPair::new_ed25519().unwrap(); -// let key_bob = ed25519_to_x25519_keypair(key_bob).unwrap(); - -// let ping = TrustPing::new("trust-ping/1.0/ping".to_string()); - -// let recipients = slice::from_ref(key_alice.public()); - -// let encoded_envelope_ping: Encrypted = ping -// .pack_auth(EncryptionAlgorithm::A256GCM, recipients, &key_bob) -// .unwrap(); - -// let tp: TrustPing = encoded_envelope_ping -// .unpack(EncryptionAlgorithm::A256GCM, key_alice.secret(), key_bob.public()) -// .unwrap(); - -// assert_eq!(format!("{:?}", tp), format!("{:?}", ping)); -// } diff --git a/identity/src/lib.rs b/identity/src/lib.rs index ba12d4074d..bab3d1b6be 100644 --- a/identity/src/lib.rs +++ b/identity/src/lib.rs @@ -104,7 +104,6 @@ pub mod comm { pub use identity_comm::envelope::*; pub use identity_comm::error::*; pub use identity_comm::message::*; - pub use identity_comm::types::*; } pub mod prelude {