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 /// Opaque issuer-attested application bytes, up to 4096 bytes.
67 pub ext: Option<ic_wire::Bytes<{ ic_auth_protocol_types::MAX_TOKEN_EXT_BYTES }>>,
68}
69
70///
71/// SessionReadRefusal
72///
73/// Existing read-refusal discriminants, in their fixed Wire order.
74///
75
76#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
77#[cfg_attr(feature = "typescript", derive(ic_wire::typescript::Wire))]
78pub enum SessionReadRefusal {
79 /// No live local session.
80 MissingOrExpired,
81 /// Protected authority is not ready.
82 AuthorityUnavailable,
83 /// The required scope is not granted.
84 ScopeRejected,
85 /// Revocation prevents use.
86 Revoked,
87 /// The read could not be completed.
88 Unavailable,
89}
90
91///
92/// LogoutUnavailable
93///
94/// Existing unavailable-logout discriminants, in their fixed Wire order.
95///
96
97#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
98#[cfg_attr(feature = "typescript", derive(ic_wire::typescript::Wire))]
99pub enum LogoutUnavailable {
100 /// No capacity to retain the required denial.
101 Capacity,
102 /// Storage could not commit the denial.
103 Storage,
104 /// Trusted time could not support the operation.
105 Clock,
106 /// A reset is pending.
107 ResetPending,
108}
109
110///
111/// LogoutResult
112///
113/// Local logout result; no variant acknowledges logout at another receiver.
114///
115
116#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
117#[cfg_attr(feature = "typescript", derive(ic_wire::typescript::Wire))]
118pub enum LogoutResult {
119 /// Committed denial through this nanosecond deadline.
120 Revoked(u64),
121 /// Local denial deadline without confirmation of outstanding issuance.
122 Unconfirmed(u64),
123 /// The host-authenticated caller is not a valid logout identity.
124 InvalidCaller,
125 /// No revocation acknowledgement; issuance uncertainty must be retained.
126 Unavailable(LogoutUnavailable),
127}