Skip to main content

DelegationApi

Struct DelegationApi 

Source
pub struct DelegationApi;
Expand description

DelegationApi

Requires auth.delegated_tokens.enabled = true in config.

Implementations§

Source§

impl DelegationApi

Source

pub async fn admin( cmd: DelegationAdminCommand, ) -> Result<DelegationAdminResponse, Error>

Execute explicit root-controlled delegation repair/prewarm operations.

Source§

impl DelegationApi

Source§

impl DelegationApi

Source

pub fn set_delegated_session_subject( delegated_subject: Principal, bootstrap_token: DelegatedToken, requested_ttl_secs: Option<u64>, ) -> Result<(), Error>

Persist a temporary delegated session subject for the caller wallet.

Source

pub fn clear_delegated_session()

Remove the caller’s delegated session subject.

Source

pub fn delegated_session_subject() -> Option<Principal>

Read the caller’s active delegated session subject, if configured.

Source

pub fn prune_expired_delegated_sessions() -> usize

Prune all currently expired delegated sessions.

Source§

impl DelegationApi

Source

pub fn verify_delegation_proof( proof: &DelegationProof, authority_pid: Principal, ) -> Result<(), Error>

Full delegation proof verification (structure + signature).

Purely local verification; does not read certified data or require a query context.

Source

pub fn has_signing_proof() -> bool

Return whether this canister currently has a local signing proof.

Source

pub async fn local_shard_public_key_sec1() -> Result<Vec<u8>, Error>

Resolve the local shard public key in SEC1 encoding.

Source

pub async fn issue_token( claims: DelegatedTokenClaims, ) -> Result<DelegatedToken, Error>

Issue a delegated token using a reusable local proof when possible.

If the proof is missing or no longer valid for the requested claims, this performs canonical shard-initiated setup and retries with the refreshed proof.

Source

pub fn verify_token( token: &DelegatedToken, authority_pid: Principal, now_secs: u64, ) -> Result<(), Error>

Full delegated token verification (structure + signature).

Purely local verification; does not read certified data or require a query context.

Source

pub fn verify_token_verified( token: &DelegatedToken, authority_pid: Principal, now_secs: u64, ) -> Result<(DelegatedTokenClaims, DelegationCert), Error>

Verify a delegated token and return verified contents.

This is intended for application-layer session construction. It performs full verification and returns verified claims and cert.

Source

pub fn verify_token_for_caller( token: &DelegatedToken, authority_pid: Principal, now_secs: u64, ) -> Result<(DelegatedTokenClaims, DelegationCert), Error>

Verify a delegated token and require its subject to match msg_caller().

This issuer-side helper does not require the old token audience to include the local signer, which allows stale-audience reissue flows.

Source

pub async fn reissue_token<A>( token: DelegatedToken, aud: A, ) -> Result<DelegatedToken, Error>

Reissue a caller-bound token for a new audience without extending expiry.

Scopes and ext are preserved. The replacement expiry is capped at the old token expiry, so this refreshes audience only and does not renew the session.

Source

pub async fn ensure_token<A>( token: Option<DelegatedToken>, aud: A, ) -> Result<DelegatedToken, Error>

Ensure the caller has a valid delegated token for the requested audience.

With no token, this mints a default verify-scoped token for msg_caller(). With a caller-bound token, this returns it unchanged when it already covers the audience or reissues it without extending expiry.

Source

pub async fn reissue_token_from_verified( old_claims: DelegatedTokenClaims, replacement_claims: DelegatedTokenClaims, ) -> Result<DelegatedToken, Error>

Reissue a token from previously verified claims and proposed claims.

CANIC enforces same sub, same shard_pid, no expiry extension, and a default scope-subset rule.

Source

pub async fn request_delegation( request: DelegationRequest, ) -> Result<DelegationProvisionResponse, Error>

Canonical shard-initiated delegation request (user_shard -> root).

Caller must match shard_pid and be registered to the subnet.

Source

pub async fn request_role_attestation( request: RoleAttestationRequest, ) -> Result<SignedRoleAttestation, Error>

Source

pub async fn attestation_key_set() -> Result<AttestationKeySet, Error>

Source

pub async fn prewarm_root_key_material() -> Result<(), Error>

Warm the root delegation and attestation key caches once.

Source

pub fn replace_attestation_key_set(key_set: AttestationKeySet)

Source

pub async fn verify_role_attestation( attestation: &SignedRoleAttestation, min_accepted_epoch: u64, ) -> Result<(), Error>

Source§

impl DelegationApi

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.