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/// Session-admission refusals in their fixed transport order.
17#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
18#[cfg_attr(feature = "typescript", derive(ic_wire::typescript::Wire))]
19pub enum AdmissionRefusal {
20    /// Credential is not yet valid at trusted time.
21    NotYetValid,
22    /// Credential has expired for fresh admission.
23    Expired,
24    /// Credential verification failed.
25    InvalidCredential,
26    /// Protected authority is not ready.
27    AuthorityUnavailable,
28    /// Credential predates the protected reset boundary.
29    BeforeReset,
30    /// Requested scopes are not admitted.
31    ScopeRejected,
32    /// A consumed credential conflicts with this request.
33    ReplayConflict,
34    /// Retained revocation prevents admission.
35    Revoked,
36    /// Required bounded state has no capacity.
37    Capacity,
38    /// The applicable attempt budget is exhausted.
39    Throttled,
40    /// Admission could not be completed.
41    Unavailable,
42}
43
44/// A local session receipt; receiving or constructing it grants no authority.
45#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
46#[cfg_attr(feature = "typescript", derive(ic_wire::typescript::Wire))]
47pub struct SessionView {
48    /// Host-authenticated browser principal bound to the session.
49    pub caller: Principal,
50    /// Issuer qualifying the subject.
51    pub issuer: Principal,
52    /// Issuer-qualified account subject.
53    pub subject: Principal,
54    /// Exclusive local lease deadline in nanoseconds.
55    pub expires_at_ns: u64,
56}
57
58/// Existing read-refusal discriminants, in their fixed Wire order.
59#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
60#[cfg_attr(feature = "typescript", derive(ic_wire::typescript::Wire))]
61pub enum SessionReadRefusal {
62    /// No live local session.
63    MissingOrExpired,
64    /// Protected authority is not ready.
65    AuthorityUnavailable,
66    /// The required scope is not granted.
67    ScopeRejected,
68    /// Revocation prevents use.
69    Revoked,
70    /// The read could not be completed.
71    Unavailable,
72}
73
74/// Existing unavailable-logout discriminants, in their fixed Wire order.
75#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
76#[cfg_attr(feature = "typescript", derive(ic_wire::typescript::Wire))]
77pub enum LogoutUnavailable {
78    /// No capacity to retain the required denial.
79    Capacity,
80    /// Storage could not commit the denial.
81    Storage,
82    /// Trusted time could not support the operation.
83    Clock,
84    /// A reset is pending.
85    ResetPending,
86}
87
88/// Local logout result; no variant acknowledges logout at another receiver.
89#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
90#[cfg_attr(feature = "typescript", derive(ic_wire::typescript::Wire))]
91pub enum LogoutResult {
92    /// Committed denial through this nanosecond deadline.
93    Revoked(u64),
94    /// Local denial deadline without confirmation of outstanding issuance.
95    Unconfirmed(u64),
96    /// The host-authenticated caller is not a valid logout identity.
97    InvalidCaller,
98    /// No revocation acknowledgement; issuance uncertainty must be retained.
99    Unavailable(LogoutUnavailable),
100}