did-resolver-cheqd 1.0.1

DID Resolver Rust implementation for did:cheqd method, using the ssi crate and Cheqd GRPC APIs
Documentation
// This file is @generated by prost-build.
/// DidDoc defines a DID Document, as defined in the DID Core specification.
/// Documentation: <https://www.w3.org/TR/did-core/>
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DidDoc {
    /// context is a list of URIs used to identify the context of the DID document.
    /// Default: <https://www.w3.org/ns/did/v1>
    #[prost(string, repeated, tag = "1")]
    pub context: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    /// id is the DID of the DID document.
    /// Format: did:cheqd:`<namespace>`:`<unique-identifier>`
    #[prost(string, tag = "2")]
    pub id: ::prost::alloc::string::String,
    /// controller is a list of DIDs that are allowed to control the DID document.
    #[prost(string, repeated, tag = "3")]
    pub controller: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    /// verificationMethod is a list of verification methods that can be used to
    /// verify a digital signature or cryptographic proof.
    #[prost(message, repeated, tag = "4")]
    pub verification_method: ::prost::alloc::vec::Vec<VerificationMethod>,
    /// authentication is a list of verification methods that can be used to
    /// authenticate as the DID subject.
    #[prost(string, repeated, tag = "5")]
    pub authentication: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    /// assertionMethod is a list of verification methods that can be used to
    /// assert statements as the DID subject.
    #[prost(string, repeated, tag = "6")]
    pub assertion_method: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    /// capabilityInvocation is a list of verification methods that can be used to
    /// invoke capabilities as the DID subject.
    #[prost(string, repeated, tag = "7")]
    pub capability_invocation: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    /// capabilityDelegation is a list of verification methods that can be used to
    /// delegate capabilities as the DID subject.
    #[prost(string, repeated, tag = "8")]
    pub capability_delegation: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    /// keyAgreement is a list of verification methods that can be used to perform
    /// key agreement as the DID subject.
    #[prost(string, repeated, tag = "9")]
    pub key_agreement: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    /// service is a list of services that can be used to interact with the DID subject.
    #[prost(message, repeated, tag = "10")]
    pub service: ::prost::alloc::vec::Vec<Service>,
    /// alsoKnownAs is a list of DIDs that are known to refer to the same DID subject.
    #[prost(string, repeated, tag = "11")]
    pub also_known_as: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
/// VerificationMethod defines a verification method, as defined in the DID Core specification.
/// Documentation: <https://www.w3.org/TR/did-core/#verification-methods>
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct VerificationMethod {
    /// id is the unique identifier of the verification method.
    /// Format: did:cheqd:`<namespace>`:`<unique-identifier>`#`<key-id>`
    #[prost(string, tag = "1")]
    pub id: ::prost::alloc::string::String,
    /// type is the type of the verification method.
    /// Example: Ed25519VerificationKey2020
    #[prost(string, tag = "2")]
    pub verification_method_type: ::prost::alloc::string::String,
    /// controller is the DID of the controller of the verification method.
    /// Format: did:cheqd:`<namespace>`:`<unique-identifier>`
    #[prost(string, tag = "3")]
    pub controller: ::prost::alloc::string::String,
    /// verification_material is the public key of the verification method.
    /// Commonly used verification material types: publicJwk, publicKeyBase58, publicKeyMultibase
    #[prost(string, tag = "4")]
    pub verification_material: ::prost::alloc::string::String,
}
/// Service defines a service, as defined in the DID Core specification.
/// Documentation: <https://www.w3.org/TR/did-core/#services>
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Service {
    /// id is the unique identifier of the service.
    /// Format: did:cheqd:`<namespace>`:`<unique-identifier>`#`<service-id>`
    #[prost(string, tag = "1")]
    pub id: ::prost::alloc::string::String,
    /// type is the type of the service.
    /// Example: LinkedResource
    #[prost(string, tag = "2")]
    pub service_type: ::prost::alloc::string::String,
    /// serviceEndpoint is the endpoint of the service.
    /// Example: <https://example.com/endpoint>
    #[prost(string, repeated, tag = "3")]
    pub service_endpoint: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    /// recipient key identify the recipient’s public encryption keys
    /// Format: did:cheqd:`<namespace>`:`<unique-identifier>`#`<key-id>` or did:key:`<identifier>`
    #[prost(string, repeated, tag = "4")]
    pub recipient_keys: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    /// routing keys contain a list of mediator or relay keys
    /// Format: did:cheqd:`<namespace>`:`<unique-identifier>`#`<key-id>` or did:key:`<identifier>`
    #[prost(string, repeated, tag = "5")]
    pub routing_keys: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    /// accept: list of MIME types or protocol formats the service supports.
    /// format: \["didcomm/v2", "didcomm/v1"\]
    #[prost(string, repeated, tag = "6")]
    pub accept: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    /// priority: An integer defining the priority of this service entry.
    #[prost(uint32, tag = "7")]
    pub priority: u32,
}
/// DidDocWithMetadata defines a DID Document with metadata, as defined in the DID Core specification.
/// Contains the DID Document, as well as DID Document metadata.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DidDocWithMetadata {
    /// didDocument is the DID Document.
    #[prost(message, optional, tag = "1")]
    pub did_doc: ::core::option::Option<DidDoc>,
    /// didDocumentMetadata is the DID Document metadata.
    #[prost(message, optional, tag = "2")]
    pub metadata: ::core::option::Option<Metadata>,
}
/// Metadata defines DID Document metadata, as defined in the DID Core specification.
/// Documentation: <https://www.w3.org/TR/did-core/#did-document-metadata-properties>
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Metadata {
    /// created is the timestamp of the creation of the DID Document.
    /// Format: RFC3339
    /// Example: 2021-03-10T15:16:17Z
    #[prost(message, optional, tag = "1")]
    pub created: ::core::option::Option<::prost_types::Timestamp>,
    /// updated is the timestamp of the last update of the DID Document.
    /// Format: RFC3339
    /// Example: 2021-03-10T15:16:17Z
    #[prost(message, optional, tag = "2")]
    pub updated: ::core::option::Option<::prost_types::Timestamp>,
    /// deactivated is a flag that indicates whether the DID Document is deactivated.
    /// Default: false
    #[prost(bool, tag = "3")]
    pub deactivated: bool,
    /// version_id is the version identifier of the DID Document.
    /// Format: UUID
    /// Example: 123e4567-e89b-12d3-a456-426655440000
    #[prost(string, tag = "4")]
    pub version_id: ::prost::alloc::string::String,
    /// next_version_id is the version identifier of the next version of the DID Document.
    /// Format: UUID
    /// Example: 123e4567-e89b-12d3-a456-426655440000
    #[prost(string, tag = "5")]
    pub next_version_id: ::prost::alloc::string::String,
    /// previous_version_id is the version identifier of the previous version of the DID Document.
    /// Format: UUID
    /// Example: 123e4567-e89b-12d3-a456-426655440000
    #[prost(string, tag = "6")]
    pub previous_version_id: ::prost::alloc::string::String,
}
/// QueryDidDocRequest is the request type for the Query/DidDoc method
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryDidDocRequest {
    /// DID unique identifier of the DID Document to fetch.
    /// UUID-style DIDs as well as Indy-style DID are supported.
    ///
    /// Format: did:cheqd:`<namespace>`:`<unique-identifier>`
    ///
    /// Examples:
    /// - did:cheqd:mainnet:c82f2b02-bdab-4dd7-b833-3e143745d612
    /// - did:cheqd:testnet:wGHEXrZvJxR8vw5P3UWH1j
    #[prost(string, tag = "1")]
    pub id: ::prost::alloc::string::String,
}
/// QueryDidDocResponse is the response type for the Query/DidDoc method
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryDidDocResponse {
    /// Successful resolution of the DID Document returns the following:
    /// - did_doc is the latest version of the DID Document
    /// - metadata is is the DID Document metadata associated with the latest version of the DID Document
    #[prost(message, optional, tag = "1")]
    pub value: ::core::option::Option<DidDocWithMetadata>,
}
/// QueryDidDocVersionRequest is the request type for the Query/DidDocVersion method
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryDidDocVersionRequest {
    /// DID unique identifier of the DID Document to fetch.
    /// UUID-style DIDs as well as Indy-style DID are supported.
    ///
    /// Format: did:cheqd:`<namespace>`:`<unique-identifier>`
    ///
    /// Examples:
    /// - did:cheqd:mainnet:c82f2b02-bdab-4dd7-b833-3e143745d612
    /// - did:cheqd:testnet:wGHEXrZvJxR8vw5P3UWH1j
    #[prost(string, tag = "1")]
    pub id: ::prost::alloc::string::String,
    /// Unique version identifier of the DID Document to fetch.
    /// Returns the specified version of the DID Document.
    ///
    /// Format: `<uuid>`
    ///
    /// Example: 93f2573c-eca9-4098-96cb-a1ec676a29ed
    #[prost(string, tag = "2")]
    pub version: ::prost::alloc::string::String,
}
/// QueryDidDocVersionResponse is the response type for the Query/DidDocVersion method
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryDidDocVersionResponse {
    /// Successful resolution of the DID Document returns the following:
    /// - did_doc is the requested version of the DID Document
    /// - metadata is DID Document metadata associated with the requested version of the DID Document
    #[prost(message, optional, tag = "1")]
    pub value: ::core::option::Option<DidDocWithMetadata>,
}
/// QueryAllDidDocVersionsMetadataRequest is the request type for the Query/AllDidDocVersionsMetadata method
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryAllDidDocVersionsMetadataRequest {
    /// DID unique identifier of the DID Document to fetch version metadata.
    /// UUID-style DIDs as well as Indy-style DID are supported.
    ///
    /// Format: did:cheqd:`<namespace>`:`<unique-identifier>`
    ///
    /// Examples:
    /// - did:cheqd:mainnet:c82f2b02-bdab-4dd7-b833-3e143745d612
    /// - did:cheqd:testnet:wGHEXrZvJxR8vw5P3UWH1j
    #[prost(string, tag = "1")]
    pub id: ::prost::alloc::string::String,
    /// pagination defines an optional pagination for the request.
    #[prost(message, optional, tag = "2")]
    pub pagination:
        ::core::option::Option<super::super::super::cosmos::base::query::v1beta1::PageRequest>,
}
/// QueryAllDidDocVersionsMetadataResponse is the response type for the Query/AllDidDocVersionsMetadata method
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryAllDidDocVersionsMetadataResponse {
    /// versions is the list of all versions of the requested DID Document
    #[prost(message, repeated, tag = "1")]
    pub versions: ::prost::alloc::vec::Vec<Metadata>,
    /// pagination defines the pagination in the response.
    #[prost(message, optional, tag = "2")]
    pub pagination:
        ::core::option::Option<super::super::super::cosmos::base::query::v1beta1::PageResponse>,
}
/// Generated client implementations.
pub mod query_client {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value
    )]
    use tonic::codegen::http::Uri;
    use tonic::codegen::*;
    /// Query defines the gRPC querier service for the DID module
    #[derive(Debug, Clone)]
    pub struct QueryClient<T> {
        inner: tonic::client::Grpc<T>,
    }
    impl QueryClient<tonic::transport::Channel> {
        /// Attempt to create a new client by connecting to a given endpoint.
        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
        where
            D: TryInto<tonic::transport::Endpoint>,
            D::Error: Into<StdError>,
        {
            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
            Ok(Self::new(conn))
        }
    }
    impl<T> QueryClient<T>
    where
        T: tonic::client::GrpcService<tonic::body::BoxBody>,
        T::Error: Into<StdError>,
        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
    {
        pub fn new(inner: T) -> Self {
            let inner = tonic::client::Grpc::new(inner);
            Self { inner }
        }
        pub fn with_origin(inner: T, origin: Uri) -> Self {
            let inner = tonic::client::Grpc::with_origin(inner, origin);
            Self { inner }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> QueryClient<InterceptedService<T, F>>
        where
            F: tonic::service::Interceptor,
            T::ResponseBody: Default,
            T: tonic::codegen::Service<
                    http::Request<tonic::body::BoxBody>,
                    Response = http::Response<
                        <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
                    >,
                >,
            <T as tonic::codegen::Service<http::Request<tonic::body::BoxBody>>>::Error:
                Into<StdError> + std::marker::Send + std::marker::Sync,
        {
            QueryClient::new(InterceptedService::new(inner, interceptor))
        }
        /// Compress requests with the given encoding.
        ///
        /// This requires the server to support it otherwise it might respond with an
        /// error.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.send_compressed(encoding);
            self
        }
        /// Enable decompressing responses.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.accept_compressed(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_decoding_message_size(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_encoding_message_size(limit);
            self
        }
        /// Fetch latest version of a DID Document for a given DID
        pub async fn did_doc(
            &mut self,
            request: impl tonic::IntoRequest<super::QueryDidDocRequest>,
        ) -> std::result::Result<tonic::Response<super::QueryDidDocResponse>, tonic::Status>
        {
            self.inner.ready().await.map_err(|e| {
                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
            })?;
            let codec = tonic::codec::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static("/cheqd.did.v2.Query/DidDoc");
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(GrpcMethod::new("cheqd.did.v2.Query", "DidDoc"));
            self.inner.unary(req, path, codec).await
        }
        /// Fetch specific version of a DID Document for a given DID
        pub async fn did_doc_version(
            &mut self,
            request: impl tonic::IntoRequest<super::QueryDidDocVersionRequest>,
        ) -> std::result::Result<tonic::Response<super::QueryDidDocVersionResponse>, tonic::Status>
        {
            self.inner.ready().await.map_err(|e| {
                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
            })?;
            let codec = tonic::codec::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static("/cheqd.did.v2.Query/DidDocVersion");
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(GrpcMethod::new("cheqd.did.v2.Query", "DidDocVersion"));
            self.inner.unary(req, path, codec).await
        }
        /// Fetch list of all versions of DID Documents for a given DID
        pub async fn all_did_doc_versions_metadata(
            &mut self,
            request: impl tonic::IntoRequest<super::QueryAllDidDocVersionsMetadataRequest>,
        ) -> std::result::Result<
            tonic::Response<super::QueryAllDidDocVersionsMetadataResponse>,
            tonic::Status,
        > {
            self.inner.ready().await.map_err(|e| {
                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
            })?;
            let codec = tonic::codec::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/cheqd.did.v2.Query/AllDidDocVersionsMetadata",
            );
            let mut req = request.into_request();
            req.extensions_mut().insert(GrpcMethod::new(
                "cheqd.did.v2.Query",
                "AllDidDocVersionsMetadata",
            ));
            self.inner.unary(req, path, codec).await
        }
    }
}