pub struct Roster {
pub epoch: u32,
pub certs: Vec<NodeCert>,
pub chain: KeyChain,
pub grants: Vec<DeviceGrant>,
}Expand description
The user’s devices and the current sealing epoch.
Fields§
§epoch: u32§certs: Vec<NodeCert>§chain: KeyChainDevice keys, rotations and admissions (public; sealed epoch keys inside).
grants: Vec<DeviceGrant>Device grants (roles, class). Kept only when they verify under the user key
(checked on Roster::add_grant and Roster::merge).
Implementations§
Source§impl Roster
impl Roster
pub fn new() -> Self
Sourcepub fn self_certify(
profile: &Profile,
user: &Keypair,
peer_id: &str,
label: &str,
at_ms: i64,
) -> Result<NodeCert>
pub fn self_certify( profile: &Profile, user: &Keypair, peer_id: &str, label: &str, at_ms: i64, ) -> Result<NodeCert>
The first device to hold an identity self-certifies and is the initial roster of one.
Sourcepub fn upsert(&mut self, cert: NodeCert)
pub fn upsert(&mut self, cert: NodeCert)
Insert or replace the cert for this peer id. Does not change the epoch.
pub fn get(&self, peer_id: &str) -> Option<&NodeCert>
pub fn active(&self) -> impl Iterator<Item = &NodeCert>
Sourcepub fn revoke(
&mut self,
profile: &Profile,
user: &Keypair,
peer_id: &str,
at_ms: i64,
) -> Result<NodeCert>
pub fn revoke( &mut self, profile: &Profile, user: &Keypair, peer_id: &str, at_ms: i64, ) -> Result<NodeCert>
Sign a revocation, attach it to the cert, and bump the key epoch. This alone does
not shut out a device that holds the seed: use crate::SyncState::revoke, which
also rotates to a random epoch key.
Sourcepub fn add_grant(&mut self, grant: DeviceGrant, key: &PublicKey) -> bool
pub fn add_grant(&mut self, grant: DeviceGrant, key: &PublicKey) -> bool
Add a grant if it verifies under key and is newer than the one held for that
device. Returns whether it was taken.
Sourcepub fn grant_of(&self, peer_id: &str) -> Option<&DeviceGrant>
pub fn grant_of(&self, peer_id: &str) -> Option<&DeviceGrant>
The grant in force for peer_id: the newest held, and only while its cert is
active. Grants are verified when they are added, so this does not check again.
Sourcepub fn roles_of(&self, peer_id: &str) -> Option<&[String]>
pub fn roles_of(&self, peer_id: &str) -> Option<&[String]>
The roles granted to peer_id, None when it has no grant (a device linked
before grants, or one never given any).
Sourcepub fn has_role(&self, peer_id: &str, role: &str) -> bool
pub fn has_role(&self, peer_id: &str, role: &str) -> bool
Whether peer_id holds a grant with role.
Sourcepub fn is_service(&self, peer_id: &str) -> bool
pub fn is_service(&self, peer_id: &str) -> bool
Whether peer_id was linked as a service device (no seed).
Sourcepub fn holds_keys(&self, peer_id: &str) -> bool
pub fn holds_keys(&self, peer_id: &str) -> bool
Whether peer_id may hold data keys: every device except a roster-only service
device.
Sourcepub fn scoped_types(&self, peer_id: &str) -> Option<Vec<String>>
pub fn scoped_types(&self, peer_id: &str) -> Option<Vec<String>>
The sync types peer_id holds type-scoped keys for instead of the epoch keys
(since 0.8.3; see DeviceGrant::scoped_types), while its cert is active. None
for every other device: a full device holds the epoch keys, a roster-only one none.
Sourcepub fn may_sync(&self, peer_id: &str, typ: &str) -> bool
pub fn may_sync(&self, peer_id: &str, typ: &str) -> bool
Whether peer_id may sync typ with this device (since 0.8.3): every device may,
except a service device, which may sync only the types in its grant (and their
chunk types) plus LEASE_TYPE, and nothing when its
grant is roster-only. Checked on every hello, pull, ack and lease request.
Source§impl Roster
impl Roster
Sourcepub fn check_session(
&self,
profile: &Profile,
user_key: &PublicKey,
user_id: &str,
offer: &SessionOffer<'_>,
our_types: &[String],
) -> SessionCheck
pub fn check_session( &self, profile: &Profile, user_key: &PublicKey, user_id: &str, offer: &SessionOffer<'_>, our_types: &[String], ) -> SessionCheck
Accept a session only if the cert is for user_id, verifies, is not revoked, and
the peer’s epoch is not behind ours. offered_types must intersect our_types.
Source§impl Roster
impl Roster
Sourcepub fn check_caller(
&self,
profile: &Profile,
user_key: &PublicKey,
peer: &str,
presented: Option<&NodeCert>,
) -> CallerCheck
pub fn check_caller( &self, profile: &Profile, user_key: &PublicKey, peer: &str, presented: Option<&NodeCert>, ) -> CallerCheck
Whether the caller of an app call or stream served by this device is one of the
user’s linked devices. peer must be the transport-authenticated peer id (Noise),
never one the caller sent. presented is the cert the caller sent with the call, if
any; it must match peer and the user, and a revoked one is refused, but only this
roster’s own cert admits a caller.
Source§impl Roster
impl Roster
Sourcepub fn all_views(&self) -> Vec<ChainView>
pub fn all_views(&self) -> Vec<ChainView>
The view from every root, the followed one or not. A device that is in two chains (two first roots made at once) uses these to bring the devices it approved into both, so the chains can merge.
Sourcepub fn chain_view(&self) -> ChainView
pub fn chain_view(&self) -> ChainView
Work out which rotations count, their members, and the head.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Roster
impl<'de> Deserialize<'de> for Roster
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Roster
Auto Trait Implementations§
impl Forget for Roster
impl Freeze for Roster
impl Move for Roster
impl RefUnwindSafe for Roster
impl Send for Roster
impl Sync for Roster
impl Unpin for Roster
impl UnsafeUnpin for Roster
impl UnwindSafe for Roster
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> Message for T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.