nominal_api/proto/
nominal.public_app.authentication.v1.rs

1// This file is @generated by prost-build.
2#[derive(Clone, Copy, PartialEq, ::prost::Message)]
3pub struct HealthCheckRequest {}
4#[derive(Clone, Copy, PartialEq, ::prost::Message)]
5pub struct HealthCheckResponse {
6    /// If true, that means that the public app authentication signal used by the client is set to expire.
7    /// If received, users of public clients should be advised to update their client.
8    #[prost(bool, tag = "1")]
9    pub will_expire: bool,
10}
11#[derive(Clone, Copy, PartialEq, ::prost::Message)]
12pub struct GetOidcInitRequest {}
13#[derive(Clone, PartialEq, ::prost::Message)]
14pub struct GetOidcInitResponse {
15    /// The `client_id` field as described in RFC 8252: <https://datatracker.ietf.org/doc/html/rfc7636.>
16    /// Note that this is already included in the `loginUrl` field of this response.
17    #[prost(string, tag = "1")]
18    pub client_id: ::prost::alloc::string::String,
19    /// A URL that public clients may use to prompt the user to authenticate in their browser, using the flow
20    /// described in RFC 8252: <https://datatracker.ietf.org/doc/html/rfc8252.>
21    ///
22    /// This URL must be extended with the following query parameters:
23    ///    * `redirect_uri`: one of the URLs included in the `redirectUris` field of this response.
24    ///    * `code_challenge` and `code_challenge_method`: described in RFC 8252
25    ///      <https://datatracker.ietf.org/doc/html/rfc7636.>
26    #[prost(string, tag = "2")]
27    pub login_url: ::prost::alloc::string::String,
28    /// List of absolute URLs (usually on the localhost) that public applications may use to perform an OIDC
29    /// authentication flow.
30    #[prost(string, repeated, tag = "3")]
31    pub redirect_uris: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
32}
33#[derive(Clone, PartialEq, ::prost::Message)]
34pub struct ExchangeAuthorizationCodeRequest {
35    #[prost(string, tag = "1")]
36    pub client_id: ::prost::alloc::string::String,
37    #[prost(string, tag = "2")]
38    pub code: ::prost::alloc::string::String,
39    #[prost(string, tag = "3")]
40    pub redirect_uri: ::prost::alloc::string::String,
41    #[prost(string, tag = "4")]
42    pub code_verifier: ::prost::alloc::string::String,
43}
44#[derive(Clone, PartialEq, ::prost::Message)]
45pub struct ExchangeAuthorizationCodeResponse {
46    #[prost(string, tag = "1")]
47    pub id_token: ::prost::alloc::string::String,
48    #[prost(int32, optional, tag = "2")]
49    pub expires_in: ::core::option::Option<i32>,
50    #[prost(string, optional, tag = "3")]
51    pub scope: ::core::option::Option<::prost::alloc::string::String>,
52}
53#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
54#[repr(i32)]
55pub enum PublicAppAuthenticationError {
56    Unspecified = 0,
57    NotSupported = 1,
58    Unauthenticated = 2,
59    Expired = 3,
60    UnknownClient = 4,
61    UnknownRedirectUri = 5,
62    InvalidGrant = 6,
63    InvalidClientCredentials = 7,
64}
65impl PublicAppAuthenticationError {
66    /// String value of the enum field names used in the ProtoBuf definition.
67    ///
68    /// The values are not transformed in any way and thus are considered stable
69    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
70    pub fn as_str_name(&self) -> &'static str {
71        match self {
72            Self::Unspecified => "PUBLIC_APP_AUTHENTICATION_ERROR_UNSPECIFIED",
73            Self::NotSupported => "PUBLIC_APP_AUTHENTICATION_ERROR_NOT_SUPPORTED",
74            Self::Unauthenticated => "PUBLIC_APP_AUTHENTICATION_ERROR_UNAUTHENTICATED",
75            Self::Expired => "PUBLIC_APP_AUTHENTICATION_ERROR_EXPIRED",
76            Self::UnknownClient => "PUBLIC_APP_AUTHENTICATION_ERROR_UNKNOWN_CLIENT",
77            Self::UnknownRedirectUri => {
78                "PUBLIC_APP_AUTHENTICATION_ERROR_UNKNOWN_REDIRECT_URI"
79            }
80            Self::InvalidGrant => "PUBLIC_APP_AUTHENTICATION_ERROR_INVALID_GRANT",
81            Self::InvalidClientCredentials => {
82                "PUBLIC_APP_AUTHENTICATION_ERROR_INVALID_CLIENT_CREDENTIALS"
83            }
84        }
85    }
86    /// Creates an enum from field names used in the ProtoBuf definition.
87    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
88        match value {
89            "PUBLIC_APP_AUTHENTICATION_ERROR_UNSPECIFIED" => Some(Self::Unspecified),
90            "PUBLIC_APP_AUTHENTICATION_ERROR_NOT_SUPPORTED" => Some(Self::NotSupported),
91            "PUBLIC_APP_AUTHENTICATION_ERROR_UNAUTHENTICATED" => {
92                Some(Self::Unauthenticated)
93            }
94            "PUBLIC_APP_AUTHENTICATION_ERROR_EXPIRED" => Some(Self::Expired),
95            "PUBLIC_APP_AUTHENTICATION_ERROR_UNKNOWN_CLIENT" => Some(Self::UnknownClient),
96            "PUBLIC_APP_AUTHENTICATION_ERROR_UNKNOWN_REDIRECT_URI" => {
97                Some(Self::UnknownRedirectUri)
98            }
99            "PUBLIC_APP_AUTHENTICATION_ERROR_INVALID_GRANT" => Some(Self::InvalidGrant),
100            "PUBLIC_APP_AUTHENTICATION_ERROR_INVALID_CLIENT_CREDENTIALS" => {
101                Some(Self::InvalidClientCredentials)
102            }
103            _ => None,
104        }
105    }
106}
107/// Generated client implementations.
108pub mod public_app_authentication_service_client {
109    #![allow(
110        unused_variables,
111        dead_code,
112        missing_docs,
113        clippy::wildcard_imports,
114        clippy::let_unit_value,
115    )]
116    use tonic::codegen::*;
117    use tonic::codegen::http::Uri;
118    /// Authentication intended for public applications developed by Nominal.
119    #[derive(Debug, Clone)]
120    pub struct PublicAppAuthenticationServiceClient<T> {
121        inner: tonic::client::Grpc<T>,
122    }
123    impl PublicAppAuthenticationServiceClient<tonic::transport::Channel> {
124        /// Attempt to create a new client by connecting to a given endpoint.
125        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
126        where
127            D: TryInto<tonic::transport::Endpoint>,
128            D::Error: Into<StdError>,
129        {
130            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
131            Ok(Self::new(conn))
132        }
133    }
134    impl<T> PublicAppAuthenticationServiceClient<T>
135    where
136        T: tonic::client::GrpcService<tonic::body::Body>,
137        T::Error: Into<StdError>,
138        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
139        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
140    {
141        pub fn new(inner: T) -> Self {
142            let inner = tonic::client::Grpc::new(inner);
143            Self { inner }
144        }
145        pub fn with_origin(inner: T, origin: Uri) -> Self {
146            let inner = tonic::client::Grpc::with_origin(inner, origin);
147            Self { inner }
148        }
149        pub fn with_interceptor<F>(
150            inner: T,
151            interceptor: F,
152        ) -> PublicAppAuthenticationServiceClient<InterceptedService<T, F>>
153        where
154            F: tonic::service::Interceptor,
155            T::ResponseBody: Default,
156            T: tonic::codegen::Service<
157                http::Request<tonic::body::Body>,
158                Response = http::Response<
159                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
160                >,
161            >,
162            <T as tonic::codegen::Service<
163                http::Request<tonic::body::Body>,
164            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
165        {
166            PublicAppAuthenticationServiceClient::new(
167                InterceptedService::new(inner, interceptor),
168            )
169        }
170        /// Compress requests with the given encoding.
171        ///
172        /// This requires the server to support it otherwise it might respond with an
173        /// error.
174        #[must_use]
175        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
176            self.inner = self.inner.send_compressed(encoding);
177            self
178        }
179        /// Enable decompressing responses.
180        #[must_use]
181        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
182            self.inner = self.inner.accept_compressed(encoding);
183            self
184        }
185        /// Limits the maximum size of a decoded message.
186        ///
187        /// Default: `4MB`
188        #[must_use]
189        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
190            self.inner = self.inner.max_decoding_message_size(limit);
191            self
192        }
193        /// Limits the maximum size of an encoded message.
194        ///
195        /// Default: `usize::MAX`
196        #[must_use]
197        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
198            self.inner = self.inner.max_encoding_message_size(limit);
199            self
200        }
201        /// Allows public applications to check compatibility with the target service.
202        pub async fn health_check(
203            &mut self,
204            request: impl tonic::IntoRequest<super::HealthCheckRequest>,
205        ) -> std::result::Result<
206            tonic::Response<super::HealthCheckResponse>,
207            tonic::Status,
208        > {
209            self.inner
210                .ready()
211                .await
212                .map_err(|e| {
213                    tonic::Status::unknown(
214                        format!("Service was not ready: {}", e.into()),
215                    )
216                })?;
217            let codec = tonic::codec::ProstCodec::default();
218            let path = http::uri::PathAndQuery::from_static(
219                "/nominal.public_app.authentication.v1.PublicAppAuthenticationService/HealthCheck",
220            );
221            let mut req = request.into_request();
222            req.extensions_mut()
223                .insert(
224                    GrpcMethod::new(
225                        "nominal.public_app.authentication.v1.PublicAppAuthenticationService",
226                        "HealthCheck",
227                    ),
228                );
229            self.inner.unary(req, path, codec).await
230        }
231        /// Allows public applications to obtain credentials used to initiate a user authentication flow using OIDC.
232        pub async fn get_oidc_init(
233            &mut self,
234            request: impl tonic::IntoRequest<super::GetOidcInitRequest>,
235        ) -> std::result::Result<
236            tonic::Response<super::GetOidcInitResponse>,
237            tonic::Status,
238        > {
239            self.inner
240                .ready()
241                .await
242                .map_err(|e| {
243                    tonic::Status::unknown(
244                        format!("Service was not ready: {}", e.into()),
245                    )
246                })?;
247            let codec = tonic::codec::ProstCodec::default();
248            let path = http::uri::PathAndQuery::from_static(
249                "/nominal.public_app.authentication.v1.PublicAppAuthenticationService/GetOidcInit",
250            );
251            let mut req = request.into_request();
252            req.extensions_mut()
253                .insert(
254                    GrpcMethod::new(
255                        "nominal.public_app.authentication.v1.PublicAppAuthenticationService",
256                        "GetOidcInit",
257                    ),
258                );
259            self.inner.unary(req, path, codec).await
260        }
261        /// Performs the authorization code exchange from OIDC on behalf of the client.
262        pub async fn exchange_authorization_code(
263            &mut self,
264            request: impl tonic::IntoRequest<super::ExchangeAuthorizationCodeRequest>,
265        ) -> std::result::Result<
266            tonic::Response<super::ExchangeAuthorizationCodeResponse>,
267            tonic::Status,
268        > {
269            self.inner
270                .ready()
271                .await
272                .map_err(|e| {
273                    tonic::Status::unknown(
274                        format!("Service was not ready: {}", e.into()),
275                    )
276                })?;
277            let codec = tonic::codec::ProstCodec::default();
278            let path = http::uri::PathAndQuery::from_static(
279                "/nominal.public_app.authentication.v1.PublicAppAuthenticationService/ExchangeAuthorizationCode",
280            );
281            let mut req = request.into_request();
282            req.extensions_mut()
283                .insert(
284                    GrpcMethod::new(
285                        "nominal.public_app.authentication.v1.PublicAppAuthenticationService",
286                        "ExchangeAuthorizationCode",
287                    ),
288                );
289            self.inner.unary(req, path, codec).await
290        }
291    }
292}