Skip to main content

exchange_ucan_grant

Function exchange_ucan_grant 

Source
pub async fn exchange_ucan_grant(
    state: &Arc<OAuthState>,
    subject_token: &str,
    dpop_header: Option<&str>,
    requested_scope: Option<&str>,
    audience: Option<&str>,
    subject_resolver: &dyn SubjectContextResolver,
) -> Response
Expand description

POST /oauth/token — UCAN grant (RFC 8693 token-exchange, subject_token_type = urn:hyprstream:token-type:ucan-grant).

Accepts a CBOR-encoded UCAN as the subject_token (the subset-grant) and mints a short-ttl, sender-bound access token (+ refresh token when the store is configured) for the requested access — never the whole grant (ZSP).

dpop_header is the DPoP proof header; it is MANDATORY for this grant type (ZSP: no bearer). The proof signature/htm/htu/replay are verified here via the same verify_dpop_proof the other grant types use; the resulting jkt is the sender-binding thumbprint. Passing None ⇒ invalid_request.

subject_resolver supplies the MAC clearance; DenyUnlabeledResolver denies until S8 ships the real resolver.

Fail-closed: every GrantError maps to a concrete OAuth error. There is no fallback path; authority-unreachable is a denial.