OpenAgentID documentation
Source referencesRust module referenceopenagent-oidc

openagent-oidc · exchange

Declared module signatures, types, configuration, and source documentation.

Source: openagent-sdk/bridges/oidc/rust/src/exchange.rs. SHA-256: eee1c1b9b3e003f6e61c96d3bca3af1e70494695d5060ca17447f4928ea16831.

This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.

exchange::GRANT_TYPE_TOKEN_EXCHANGE

Standard grant type for RFC 8693 Token Exchange.

pub const GRANT_TYPE_TOKEN_EXCHANGE: &str;

Source line: 13.

exchange::TOKEN_TYPE_JWT

Standard token type for JWT subject tokens.

pub const TOKEN_TYPE_JWT: &str;

Source line: 17.

exchange::TOKEN_TYPE_ACT

Custom token type for OpenAgent ACTs.

pub const TOKEN_TYPE_ACT: &str;

Source line: 20.

exchange::TOKEN_TYPE_ACCESS

Standard token type for access tokens.

pub const TOKEN_TYPE_ACCESS: &str;

Source line: 23.

exchange::TokenExchangeRequest

Token exchange request (RFC 8693 Section 2.1).

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TokenExchangeRequest {
/// Must be `urn:ietf:params:oauth:grant-type:token-exchange`.

pub grant_type: String,
/// The subject token (typically a human JWT).

pub subject_token: String,
/// Type of the subject token.

pub subject_token_type: String,
/// Desired type of the issued token.

#[serde(skip_serializing_if = "Option::is_none")]
pub requested_token_type: Option<String>,
/// Requested scopes for the exchanged token.

#[serde(skip_serializing_if = "Option::is_none")]
pub scope: Option<String>,
/// Target audience for the exchanged token.

#[serde(skip_serializing_if = "Option::is_none")]
pub audience: Option<String>,
/// Logical name of the target service.

#[serde(skip_serializing_if = "Option::is_none")]
pub resource: Option<String>,
/// Actor token (for delegation / impersonation scenarios).

#[serde(skip_serializing_if = "Option::is_none")]
pub actor_token: Option<String>,
/// Type of the actor token.

#[serde(skip_serializing_if = "Option::is_none")]
pub actor_token_type: Option<String>
}

Source line: 27.

exchange::TokenExchangeResponse

Token exchange response (RFC 8693 Section 2.2).

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TokenExchangeResponse {
/// The issued token.

pub access_token: String,
/// Type of the issued token.

pub issued_token_type: String,
/// Token type (always `"Bearer"` for our use case).

pub token_type: String,
/// Lifetime of the token in seconds.

pub expires_in: i64,
/// Scope of the issued token.

#[serde(skip_serializing_if = "Option::is_none")]
pub scope: Option<String>
}

Source line: 56.

exchange::TokenExchangeRequest::new_jwt_to_act

Create a new token exchange request for exchanging a human JWT for an ACT.

pub fn new_jwt_to_act(subject_token: impl Into<String>, scopes: &[&str]) -> Self;

Source line: 72.

exchange::TokenExchangeRequest::validate

Validate the request structure.

pub fn validate(&self) -> Result<()>;

Source line: 91.

exchange::TokenExchangeRequest::requested_scopes

Parse requested scopes into a vector.

pub fn requested_scopes(&self) -> Vec<String>;

Source line: 133.

exchange::TokenExchangeResponse::success

Build a successful token exchange response.

pub fn success(
        access_token: impl Into<String>,
        issued_token_type: impl Into<String>,
        expires_in: i64,
        scope: Option<String>,
    ) -> Self;

Source line: 143.

exchange::TokenExchangeError

RFC 8693 error response.

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TokenExchangeError {
/// Error code (per RFC 6749 Section 5.2).

pub error: String,
/// Human-readable error description.

#[serde(skip_serializing_if = "Option::is_none")]
pub error_description: Option<String>
}

Source line: 161.

exchange::TokenExchangeError::invalid_request

Create an invalid_request error.

pub fn invalid_request(description: impl Into<String>) -> Self;

Source line: 171.

exchange::TokenExchangeError::invalid_grant

Create an invalid_grant error (e.g., JWT validation failed).

pub fn invalid_grant(description: impl Into<String>) -> Self;

Source line: 179.

exchange::TokenExchangeError::unsupported_token_type

Create an unsupported_token_type error.

pub fn unsupported_token_type(description: impl Into<String>) -> Self;

Source line: 187.

exchange::TokenExchangeError::invalid_target

Create an invalid_target error.

pub fn invalid_target(description: impl Into<String>) -> Self;

Source line: 195.

On this page