nominal-api 0.1194.0

API bindings for the Nominal platform
Documentation
// This file is @generated by prost-build.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct HealthCheckRequest {}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct HealthCheckResponse {
    /// If true, that means that the public app authentication signal used by the client is set to expire.
    /// If received, users of public clients should be advised to update their client.
    #[prost(bool, tag = "1")]
    pub will_expire: bool,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct GetOidcInitRequest {}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetOidcInitResponse {
    /// The `client_id` field as described in RFC 8252: <https://datatracker.ietf.org/doc/html/rfc7636.>
    /// Note that this is already included in the `loginUrl` field of this response.
    #[prost(string, tag = "1")]
    pub client_id: ::prost::alloc::string::String,
    /// A URL that public clients may use to prompt the user to authenticate in their browser, using the flow
    /// described in RFC 8252: <https://datatracker.ietf.org/doc/html/rfc8252.>
    ///
    /// This URL must be extended with the following query parameters:
    ///    * `redirect_uri`: one of the URLs included in the `redirectUris` field of this response.
    ///    * `code_challenge` and `code_challenge_method`: described in RFC 8252
    ///      <https://datatracker.ietf.org/doc/html/rfc7636.>
    #[prost(string, tag = "2")]
    pub login_url: ::prost::alloc::string::String,
    /// List of absolute URLs (usually on the localhost) that public applications may use to perform an OIDC
    /// authentication flow.
    #[prost(string, repeated, tag = "3")]
    pub redirect_uris: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExchangeAuthorizationCodeRequest {
    #[prost(string, tag = "1")]
    pub client_id: ::prost::alloc::string::String,
    #[prost(string, tag = "2")]
    pub code: ::prost::alloc::string::String,
    #[prost(string, tag = "3")]
    pub redirect_uri: ::prost::alloc::string::String,
    #[prost(string, tag = "4")]
    pub code_verifier: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExchangeAuthorizationCodeResponse {
    #[prost(string, tag = "1")]
    pub id_token: ::prost::alloc::string::String,
    #[prost(int32, optional, tag = "2")]
    pub expires_in: ::core::option::Option<i32>,
    #[prost(string, optional, tag = "3")]
    pub scope: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(string, optional, tag = "4")]
    pub access_token: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum PublicAppAuthenticationError {
    Unspecified = 0,
    NotSupported = 1,
    Unauthenticated = 2,
    Expired = 3,
    UnknownClient = 4,
    UnknownRedirectUri = 5,
    InvalidGrant = 6,
    InvalidClientCredentials = 7,
}
impl PublicAppAuthenticationError {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unspecified => "PUBLIC_APP_AUTHENTICATION_ERROR_UNSPECIFIED",
            Self::NotSupported => "PUBLIC_APP_AUTHENTICATION_ERROR_NOT_SUPPORTED",
            Self::Unauthenticated => "PUBLIC_APP_AUTHENTICATION_ERROR_UNAUTHENTICATED",
            Self::Expired => "PUBLIC_APP_AUTHENTICATION_ERROR_EXPIRED",
            Self::UnknownClient => "PUBLIC_APP_AUTHENTICATION_ERROR_UNKNOWN_CLIENT",
            Self::UnknownRedirectUri => {
                "PUBLIC_APP_AUTHENTICATION_ERROR_UNKNOWN_REDIRECT_URI"
            }
            Self::InvalidGrant => "PUBLIC_APP_AUTHENTICATION_ERROR_INVALID_GRANT",
            Self::InvalidClientCredentials => {
                "PUBLIC_APP_AUTHENTICATION_ERROR_INVALID_CLIENT_CREDENTIALS"
            }
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "PUBLIC_APP_AUTHENTICATION_ERROR_UNSPECIFIED" => Some(Self::Unspecified),
            "PUBLIC_APP_AUTHENTICATION_ERROR_NOT_SUPPORTED" => Some(Self::NotSupported),
            "PUBLIC_APP_AUTHENTICATION_ERROR_UNAUTHENTICATED" => {
                Some(Self::Unauthenticated)
            }
            "PUBLIC_APP_AUTHENTICATION_ERROR_EXPIRED" => Some(Self::Expired),
            "PUBLIC_APP_AUTHENTICATION_ERROR_UNKNOWN_CLIENT" => Some(Self::UnknownClient),
            "PUBLIC_APP_AUTHENTICATION_ERROR_UNKNOWN_REDIRECT_URI" => {
                Some(Self::UnknownRedirectUri)
            }
            "PUBLIC_APP_AUTHENTICATION_ERROR_INVALID_GRANT" => Some(Self::InvalidGrant),
            "PUBLIC_APP_AUTHENTICATION_ERROR_INVALID_CLIENT_CREDENTIALS" => {
                Some(Self::InvalidClientCredentials)
            }
            _ => None,
        }
    }
}
/// Generated client implementations.
pub mod public_app_authentication_service_client {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    use tonic::codegen::http::Uri;
    /// Authentication intended for public applications developed by Nominal.
    #[derive(Debug, Clone)]
    pub struct PublicAppAuthenticationServiceClient<T> {
        inner: tonic::client::Grpc<T>,
    }
    impl PublicAppAuthenticationServiceClient<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> PublicAppAuthenticationServiceClient<T>
    where
        T: tonic::client::GrpcService<tonic::body::Body>,
        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,
        ) -> PublicAppAuthenticationServiceClient<InterceptedService<T, F>>
        where
            F: tonic::service::Interceptor,
            T::ResponseBody: Default,
            T: tonic::codegen::Service<
                http::Request<tonic::body::Body>,
                Response = http::Response<
                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
                >,
            >,
            <T as tonic::codegen::Service<
                http::Request<tonic::body::Body>,
            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
        {
            PublicAppAuthenticationServiceClient::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
        }
        /// Allows public applications to check compatibility with the target service.
        pub async fn health_check(
            &mut self,
            request: impl tonic::IntoRequest<super::HealthCheckRequest>,
        ) -> std::result::Result<
            tonic::Response<super::HealthCheckResponse>,
            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(
                "/nominal.public_app.authentication.v1.PublicAppAuthenticationService/HealthCheck",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "nominal.public_app.authentication.v1.PublicAppAuthenticationService",
                        "HealthCheck",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Allows public applications to obtain credentials used to initiate a user authentication flow using OIDC.
        pub async fn get_oidc_init(
            &mut self,
            request: impl tonic::IntoRequest<super::GetOidcInitRequest>,
        ) -> std::result::Result<
            tonic::Response<super::GetOidcInitResponse>,
            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(
                "/nominal.public_app.authentication.v1.PublicAppAuthenticationService/GetOidcInit",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "nominal.public_app.authentication.v1.PublicAppAuthenticationService",
                        "GetOidcInit",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Performs the authorization code exchange from OIDC on behalf of the client.
        pub async fn exchange_authorization_code(
            &mut self,
            request: impl tonic::IntoRequest<super::ExchangeAuthorizationCodeRequest>,
        ) -> std::result::Result<
            tonic::Response<super::ExchangeAuthorizationCodeResponse>,
            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(
                "/nominal.public_app.authentication.v1.PublicAppAuthenticationService/ExchangeAuthorizationCode",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "nominal.public_app.authentication.v1.PublicAppAuthenticationService",
                        "ExchangeAuthorizationCode",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
    }
}