pub struct UcanToken {
pub version: String,
pub issuer: String,
pub audience: String,
pub capabilities: Vec<Capability>,
pub expiration: i64,
pub not_before: Option<i64>,
pub nonce: String,
pub proof: Vec<String>,
pub signature: String,
}Expand description
A UCAN token for capability delegation
Fields§
§version: StringToken version
issuer: StringIssuer DID (the delegator)
audience: StringAudience DID (the delegatee)
capabilities: Vec<Capability>Capabilities being delegated
expiration: i64Expiration timestamp (Unix epoch seconds)
not_before: Option<i64>Not-before timestamp
nonce: StringNonce for uniqueness
proof: Vec<String>Proof chain — parent UCAN CIDs that authorize this delegation
signature: StringSignature of the token payload by the issuer
Implementations§
Source§impl UcanToken
impl UcanToken
Sourcepub fn new(
issuer: String,
audience: String,
capabilities: Vec<Capability>,
duration_secs: i64,
) -> Self
pub fn new( issuer: String, audience: String, capabilities: Vec<Capability>, duration_secs: i64, ) -> Self
Create a new UCAN token (unsigned)
Sourcepub fn sign(&mut self, private_key_hex: &str) -> Result<(), LitError>
pub fn sign(&mut self, private_key_hex: &str) -> Result<(), LitError>
Sign the token with the issuer’s private key material
Sourcepub fn verify(&self, issuer_public_key_hex: &str) -> Result<bool, LitError>
pub fn verify(&self, issuer_public_key_hex: &str) -> Result<bool, LitError>
Verify the token’s signature
Sourcepub fn has_capability(&self, resource: &str, action: &str) -> bool
pub fn has_capability(&self, resource: &str, action: &str) -> bool
Check if this token grants a specific capability
Trait Implementations§
Source§impl<'de> Deserialize<'de> for UcanToken
impl<'de> Deserialize<'de> for UcanToken
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for UcanToken
impl RefUnwindSafe for UcanToken
impl Send for UcanToken
impl Sync for UcanToken
impl Unpin for UcanToken
impl UnsafeUnpin for UcanToken
impl UnwindSafe for UcanToken
Blanket Implementations§
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
Mutably borrows from an owned value. Read more