matrix_sdk/widget/machine/
openid.rs1use std::time::Duration;
16
17use ruma::{
18 OwnedServerName, api::client::account::request_openid_token, authentication::TokenType,
19};
20use serde::{Deserialize, Serialize};
21
22#[derive(Clone, Debug, Deserialize, Serialize)]
23pub(crate) struct OpenIdState {
24 pub(crate) original_request_id: String,
25 pub(crate) access_token: String,
26 #[serde(with = "ruma::serde::duration::secs")]
27 pub(crate) expires_in: Duration,
28 pub(crate) matrix_server_name: OwnedServerName,
29 pub(crate) token_type: TokenType,
30}
31
32impl OpenIdState {
33 pub(crate) fn new(id: String, ruma: request_openid_token::v3::Response) -> Self {
34 Self {
35 original_request_id: id,
36 access_token: ruma.access_token,
37 expires_in: ruma.expires_in,
38 matrix_server_name: ruma.matrix_server_name,
39 token_type: ruma.token_type,
40 }
41 }
42}
43
44#[derive(Clone, Debug, Deserialize, Serialize)]
45#[serde(rename_all = "lowercase")]
46#[serde(tag = "state")]
47pub(crate) enum OpenIdResponse {
48 Allowed(OpenIdState),
49 Blocked {
50 original_request_id: String,
51 },
52 #[serde(rename = "request")]
53 Pending,
54}