Skip to main content

ic_auth_wire/model/
mod.rs

1//! Transport records and discriminants, kept distinct from engine decisions.
2
3mod credential;
4
5use ic_auth_protocol_types::Principal;
6use serde::{Deserialize, Serialize};
7
8pub use credential::{
9    AudienceId, CertifiedProof, ChainKeyAlgorithm, ChainKeyBatchHeaderV1,
10    ChainKeyBatchWitnessStepV1, ChainKeyBatchWitnessV1, ChainKeyDelegationCertV1, ChainKeyKeyId,
11    ChainKeyRootSignatureV1, DelegatedRoleGrant, DelegationAudience, DelegationCert,
12    DelegationProof, IcCanisterSignatureProofV1, IcChainKeyBatchSignatureProofV1,
13    IssuerProofAlgorithm, IssuerProofBinding, PortableCredential, PortableProof, RootProof,
14};
15
16///
17/// AdmissionRefusal
18///
19/// Session-admission refusals in their fixed transport order.
20///
21
22#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
23#[cfg_attr(feature = "typescript", derive(ic_wire::typescript::Wire))]
24pub enum AdmissionRefusal {
25    /// Credential is not yet valid at trusted time.
26    NotYetValid,
27    /// Credential has expired for fresh admission.
28    Expired,
29    /// Credential verification failed.
30    InvalidCredential,
31    /// Protected authority is not ready.
32    AuthorityUnavailable,
33    /// Credential predates the protected reset boundary.
34    BeforeReset,
35    /// Requested scopes are not admitted.
36    ScopeRejected,
37    /// A consumed credential conflicts with this request.
38    ReplayConflict,
39    /// Retained revocation prevents admission.
40    Revoked,
41    /// Required bounded state has no capacity.
42    Capacity,
43    /// The applicable attempt budget is exhausted.
44    Throttled,
45    /// Admission could not be completed.
46    Unavailable,
47}
48
49///
50/// SessionView
51///
52/// A local session receipt; receiving or constructing it grants no authority.
53///
54
55#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
56#[cfg_attr(feature = "typescript", derive(ic_wire::typescript::Wire))]
57pub struct SessionView {
58    /// Host-authenticated browser principal bound to the session.
59    pub caller: Principal,
60    /// Issuer qualifying the subject.
61    pub issuer: Principal,
62    /// Issuer-qualified account subject.
63    pub subject: Principal,
64    /// Exclusive local lease deadline in nanoseconds.
65    pub expires_at_ns: u64,
66}
67
68///
69/// SessionReadRefusal
70///
71/// Existing read-refusal discriminants, in their fixed Wire order.
72///
73
74#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
75#[cfg_attr(feature = "typescript", derive(ic_wire::typescript::Wire))]
76pub enum SessionReadRefusal {
77    /// No live local session.
78    MissingOrExpired,
79    /// Protected authority is not ready.
80    AuthorityUnavailable,
81    /// The required scope is not granted.
82    ScopeRejected,
83    /// Revocation prevents use.
84    Revoked,
85    /// The read could not be completed.
86    Unavailable,
87}
88
89///
90/// LogoutUnavailable
91///
92/// Existing unavailable-logout discriminants, in their fixed Wire order.
93///
94
95#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
96#[cfg_attr(feature = "typescript", derive(ic_wire::typescript::Wire))]
97pub enum LogoutUnavailable {
98    /// No capacity to retain the required denial.
99    Capacity,
100    /// Storage could not commit the denial.
101    Storage,
102    /// Trusted time could not support the operation.
103    Clock,
104    /// A reset is pending.
105    ResetPending,
106}
107
108///
109/// LogoutResult
110///
111/// Local logout result; no variant acknowledges logout at another receiver.
112///
113
114#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
115#[cfg_attr(feature = "typescript", derive(ic_wire::typescript::Wire))]
116pub enum LogoutResult {
117    /// Committed denial through this nanosecond deadline.
118    Revoked(u64),
119    /// Local denial deadline without confirmation of outstanding issuance.
120    Unconfirmed(u64),
121    /// The host-authenticated caller is not a valid logout identity.
122    InvalidCaller,
123    /// No revocation acknowledgement; issuance uncertainty must be retained.
124    Unavailable(LogoutUnavailable),
125}