Skip to main content

junobuild_auth/automation/
types.rs

1use crate::openid::jwkset::types::errors::GetOrRefreshJwksError;
2use crate::openid::jwt::types::errors::{JwtFindProviderError, JwtVerifyError};
3use crate::state::types::state::Salt;
4use candid::{CandidType, Deserialize};
5use junobuild_shared::types::state::ControllerId;
6use serde::Serialize;
7
8#[derive(CandidType, Serialize, Deserialize)]
9pub struct OpenIdPrepareAutomationArgs {
10    pub jwt: String,
11    pub salt: Salt,
12}
13
14pub type PrepareAutomationResult = Result<PreparedAutomation, PrepareAutomationError>;
15
16#[derive(CandidType, Serialize, Deserialize)]
17pub struct PreparedAutomation(pub ControllerId, pub AutomationController);
18
19#[derive(CandidType, Serialize, Deserialize)]
20pub struct AutomationController {
21    pub scope: AutomationScope,
22    pub expires_at: u64,
23}
24
25#[derive(CandidType, Serialize, Deserialize, Clone, Debug)]
26pub enum AutomationScope {
27    Write,
28    Submit,
29}
30
31#[derive(CandidType, Serialize, Deserialize, Debug)]
32pub enum PrepareAutomationError {
33    ControllerAlreadyExists,
34    InvalidController(String),
35    TooManyControllers(String),
36    InvalidObservatoryId(String),
37    GetOrFetchJwks(GetOrRefreshJwksError),
38    GetCachedJwks,
39    JwtFindProvider(JwtFindProviderError),
40    JwtVerify(JwtVerifyError),
41}