//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `auth/refresh`. Version: `0.1`.
#![allow(deprecated)]
/// Why this specification version is deprecated (SPEC "Superseded and
/// Withdrawn Versions"), or `None` while it is current.
pub const DEPRECATION: Option<&str> = Some("superseded by auth/refresh/0.2");
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
///Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct Ext(pub ::std::collections::HashMap<ExtKey, ::serde_json::Value>);
impl ::std::ops::Deref for Ext {
type Target = ::std::collections::HashMap<ExtKey, ::serde_json::Value>;
fn deref(&self) -> &::std::collections::HashMap<ExtKey, ::serde_json::Value> {
&self.0
}
}
impl ::std::convert::From<Ext> for ::std::collections::HashMap<ExtKey, ::serde_json::Value> {
fn from(value: Ext) -> Self {
value.0
}
}
impl ::std::convert::From<::std::collections::HashMap<ExtKey, ::serde_json::Value>> for Ext {
fn from(value: ::std::collections::HashMap<ExtKey, ::serde_json::Value>) -> Self {
Self(value)
}
}
///`ExtKey`
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ExtKey(::std::string::String);
impl ::std::ops::Deref for ExtKey {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ExtKey> for ::std::string::String {
fn from(value: ExtKey) -> Self {
value.0
}
}
impl ::std::str::FromStr for ExtKey {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ExtKey {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Exchange a refresh token for a new access token (and optionally a new refresh token).
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
#[deprecated(note = "superseded by auth/refresh/0.2")]
pub struct Payload {
///Ecosystem-defined extension members per SPEC.md §4.5.1.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///The refresh token previously issued in a TokenBundle. Consumers verify it server-side; producers treat it as opaque.
#[serde(rename = "refreshToken")]
pub refresh_token: PayloadRefreshToken,
///Optional capability tags requested on the new access token. MAY be narrower than the original session's scope; consumers MUST NOT widen scope on refresh.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub scope: ::std::vec::Vec<PayloadScopeItem>,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///The refresh token previously issued in a TokenBundle. Consumers verify it server-side; producers treat it as opaque.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadRefreshToken(::std::string::String);
impl ::std::ops::Deref for PayloadRefreshToken {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadRefreshToken> for ::std::string::String {
fn from(value: PayloadRefreshToken) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadRefreshToken {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadRefreshToken {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for PayloadRefreshToken {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for PayloadRefreshToken {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for PayloadRefreshToken {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`PayloadScopeItem`
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadScopeItem(::std::string::String);
impl ::std::ops::Deref for PayloadScopeItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadScopeItem> for ::std::string::String {
fn from(value: PayloadScopeItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadScopeItem {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadScopeItem {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for PayloadScopeItem {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for PayloadScopeItem {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for PayloadScopeItem {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Issued by the auth service when the presented refresh token is valid. Carried in a Trust Task document whose type is https://trusttasks.org/spec/auth/refresh/0.1#response.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
#[deprecated(note = "superseded by auth/refresh/0.2")]
pub struct Response {
///Ecosystem-defined extension members per SPEC.md §4.5.1.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///Optional session snapshot. Consumers SHOULD include it so the producer can refresh client-side state (acr changes after step-up, scope changes after policy edits) without a separate whoami call.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub session: ::std::option::Option<Session>,
///New access token. If the consumer's policy rotates refresh tokens on each use, a new refreshToken is included; otherwise the producer continues using the previously-issued one.
pub tokens: TokenBundle,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///A logical authentication context bound to a subject. Producers and consumers exchange Session-shaped data in challenge issuance, authentication responses, and introspection (whoami).
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Session {
///Authentication Context Class Reference per [OIDC Core §2]. Profiles define their own values; the recommended set is "aal1" (single-factor DID auth), "aal2" (a second possession-or-biometric factor confirmed), and "aal3" (hardware-bound second factor).
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub acr: ::std::option::Option<::std::string::String>,
///Authentication Methods References per [RFC 8176]. Typical values: "did" (challenge-response), "passkey" (WebAuthn), "vta" (verifiable-trust agent approval). Multi-factor sessions list every method used.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub amr: ::std::vec::Vec<SessionAmrItem>,
///ISO-8601 timestamp when the session ceases to be valid. Producers SHOULD refresh before this time; consumers MUST reject after.
#[serde(rename = "expiresAt")]
pub expires_at: ::chrono::DateTime<::chrono::offset::Utc>,
///Ecosystem-defined extension members per SPEC.md §4.5.1.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///Opaque, server-chosen session identifier. Stable for the lifetime of the session. Consumers MUST treat the value as opaque; no structure is implied.
pub id: SessionId,
///ISO-8601 timestamp when the session was created.
#[serde(rename = "issuedAt")]
pub issued_at: ::chrono::DateTime<::chrono::offset::Utc>,
///The authenticated party's VID (typically a DID URL).
pub subject: SessionSubject,
}
impl Session {
pub fn builder() -> builder::Session {
Default::default()
}
}
///`SessionAmrItem`
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct SessionAmrItem(::std::string::String);
impl ::std::ops::Deref for SessionAmrItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<SessionAmrItem> for ::std::string::String {
fn from(value: SessionAmrItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for SessionAmrItem {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for SessionAmrItem {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for SessionAmrItem {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for SessionAmrItem {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for SessionAmrItem {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Opaque, server-chosen session identifier. Stable for the lifetime of the session. Consumers MUST treat the value as opaque; no structure is implied.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct SessionId(::std::string::String);
impl ::std::ops::Deref for SessionId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<SessionId> for ::std::string::String {
fn from(value: SessionId) -> Self {
value.0
}
}
impl ::std::str::FromStr for SessionId {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for SessionId {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for SessionId {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for SessionId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for SessionId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///The authenticated party's VID (typically a DID URL).
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct SessionSubject(::std::string::String);
impl ::std::ops::Deref for SessionSubject {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<SessionSubject> for ::std::string::String {
fn from(value: SessionSubject) -> Self {
value.0
}
}
impl ::std::str::FromStr for SessionSubject {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for SessionSubject {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for SessionSubject {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for SessionSubject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for SessionSubject {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///An access token (typically short-lived JWT) paired with an optional refresh token (typically long-lived opaque string). The shapes follow OAuth 2.0 (RFC 6749 §5.1) conventions but are not coupled to any particular OAuth profile.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct TokenBundle {
///Bearer-style access token. Consumers presenting this token to downstream services prove the holder of the original session. Format is consumer-defined — JWT is common, but opaque strings are also valid.
#[serde(rename = "accessToken")]
pub access_token: TokenBundleAccessToken,
///Seconds from issuance until the access token expires.
#[serde(rename = "expiresIn")]
pub expires_in: ::std::num::NonZeroU64,
///Ecosystem-defined extension members per SPEC.md §4.5.1.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///Seconds from issuance until the refresh token expires, when one was issued.
#[serde(
rename = "refreshExpiresIn",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub refresh_expires_in: ::std::option::Option<::std::num::NonZeroU64>,
///Long-lived token redeemable via auth/refresh for a new access token. MAY be absent when the issuer does not support refresh.
#[serde(
rename = "refreshToken",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub refresh_token: ::std::option::Option<TokenBundleRefreshToken>,
///Capability tags effective on this token. Format is consumer-defined; the framework imposes no syntax.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub scope: ::std::vec::Vec<TokenBundleScopeItem>,
///Token presentation scheme. Almost always "Bearer"; reserved for future schemes.
#[serde(rename = "tokenType")]
pub token_type: TokenBundleTokenType,
}
impl TokenBundle {
pub fn builder() -> builder::TokenBundle {
Default::default()
}
}
///Bearer-style access token. Consumers presenting this token to downstream services prove the holder of the original session. Format is consumer-defined — JWT is common, but opaque strings are also valid.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct TokenBundleAccessToken(::std::string::String);
impl ::std::ops::Deref for TokenBundleAccessToken {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<TokenBundleAccessToken> for ::std::string::String {
fn from(value: TokenBundleAccessToken) -> Self {
value.0
}
}
impl ::std::str::FromStr for TokenBundleAccessToken {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for TokenBundleAccessToken {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for TokenBundleAccessToken {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for TokenBundleAccessToken {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for TokenBundleAccessToken {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Long-lived token redeemable via auth/refresh for a new access token. MAY be absent when the issuer does not support refresh.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct TokenBundleRefreshToken(::std::string::String);
impl ::std::ops::Deref for TokenBundleRefreshToken {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<TokenBundleRefreshToken> for ::std::string::String {
fn from(value: TokenBundleRefreshToken) -> Self {
value.0
}
}
impl ::std::str::FromStr for TokenBundleRefreshToken {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for TokenBundleRefreshToken {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for TokenBundleRefreshToken {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for TokenBundleRefreshToken {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for TokenBundleRefreshToken {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`TokenBundleScopeItem`
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct TokenBundleScopeItem(::std::string::String);
impl ::std::ops::Deref for TokenBundleScopeItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<TokenBundleScopeItem> for ::std::string::String {
fn from(value: TokenBundleScopeItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for TokenBundleScopeItem {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for TokenBundleScopeItem {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for TokenBundleScopeItem {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for TokenBundleScopeItem {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for TokenBundleScopeItem {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Token presentation scheme. Almost always "Bearer"; reserved for future schemes.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct TokenBundleTokenType(::std::string::String);
impl ::std::ops::Deref for TokenBundleTokenType {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<TokenBundleTokenType> for ::std::string::String {
fn from(value: TokenBundleTokenType) -> Self {
value.0
}
}
impl ::std::str::FromStr for TokenBundleTokenType {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for TokenBundleTokenType {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for TokenBundleTokenType {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for TokenBundleTokenType {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for TokenBundleTokenType {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Payload {
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
refresh_token: ::std::result::Result<super::PayloadRefreshToken, ::std::string::String>,
scope:
::std::result::Result<::std::vec::Vec<super::PayloadScopeItem>, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
ext: Ok(Default::default()),
refresh_token: Err("no value supplied for refresh_token".to_string()),
scope: Ok(Default::default()),
}
}
}
impl Payload {
pub fn ext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Ext>>,
T::Error: ::std::fmt::Display,
{
self.ext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ext: {e}"));
self
}
pub fn refresh_token<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadRefreshToken>,
T::Error: ::std::fmt::Display,
{
self.refresh_token = value
.try_into()
.map_err(|e| format!("error converting supplied value for refresh_token: {e}"));
self
}
pub fn scope<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::PayloadScopeItem>>,
T::Error: ::std::fmt::Display,
{
self.scope = value
.try_into()
.map_err(|e| format!("error converting supplied value for scope: {e}"));
self
}
}
impl ::std::convert::TryFrom<Payload> for super::Payload {
type Error = super::error::ConversionError;
fn try_from(value: Payload) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
ext: value.ext?,
refresh_token: value.refresh_token?,
scope: value.scope?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
ext: Ok(value.ext),
refresh_token: Ok(value.refresh_token),
scope: Ok(value.scope),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
session:
::std::result::Result<::std::option::Option<super::Session>, ::std::string::String>,
tokens: ::std::result::Result<super::TokenBundle, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
ext: Ok(Default::default()),
session: Ok(Default::default()),
tokens: Err("no value supplied for tokens".to_string()),
}
}
}
impl Response {
pub fn ext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Ext>>,
T::Error: ::std::fmt::Display,
{
self.ext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ext: {e}"));
self
}
pub fn session<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Session>>,
T::Error: ::std::fmt::Display,
{
self.session = value
.try_into()
.map_err(|e| format!("error converting supplied value for session: {e}"));
self
}
pub fn tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::TokenBundle>,
T::Error: ::std::fmt::Display,
{
self.tokens = value
.try_into()
.map_err(|e| format!("error converting supplied value for tokens: {e}"));
self
}
}
impl ::std::convert::TryFrom<Response> for super::Response {
type Error = super::error::ConversionError;
fn try_from(value: Response) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
ext: value.ext?,
session: value.session?,
tokens: value.tokens?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
ext: Ok(value.ext),
session: Ok(value.session),
tokens: Ok(value.tokens),
}
}
}
#[derive(Clone, Debug)]
pub struct Session {
acr: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
amr: ::std::result::Result<::std::vec::Vec<super::SessionAmrItem>, ::std::string::String>,
expires_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
id: ::std::result::Result<super::SessionId, ::std::string::String>,
issued_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
subject: ::std::result::Result<super::SessionSubject, ::std::string::String>,
}
impl ::std::default::Default for Session {
fn default() -> Self {
Self {
acr: Ok(Default::default()),
amr: Ok(Default::default()),
expires_at: Err("no value supplied for expires_at".to_string()),
ext: Ok(Default::default()),
id: Err("no value supplied for id".to_string()),
issued_at: Err("no value supplied for issued_at".to_string()),
subject: Err("no value supplied for subject".to_string()),
}
}
}
impl Session {
pub fn acr<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.acr = value
.try_into()
.map_err(|e| format!("error converting supplied value for acr: {e}"));
self
}
pub fn amr<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::SessionAmrItem>>,
T::Error: ::std::fmt::Display,
{
self.amr = value
.try_into()
.map_err(|e| format!("error converting supplied value for amr: {e}"));
self
}
pub fn expires_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.expires_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for expires_at: {e}"));
self
}
pub fn ext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Ext>>,
T::Error: ::std::fmt::Display,
{
self.ext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ext: {e}"));
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::SessionId>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn issued_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.issued_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for issued_at: {e}"));
self
}
pub fn subject<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::SessionSubject>,
T::Error: ::std::fmt::Display,
{
self.subject = value
.try_into()
.map_err(|e| format!("error converting supplied value for subject: {e}"));
self
}
}
impl ::std::convert::TryFrom<Session> for super::Session {
type Error = super::error::ConversionError;
fn try_from(value: Session) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
acr: value.acr?,
amr: value.amr?,
expires_at: value.expires_at?,
ext: value.ext?,
id: value.id?,
issued_at: value.issued_at?,
subject: value.subject?,
})
}
}
impl ::std::convert::From<super::Session> for Session {
fn from(value: super::Session) -> Self {
Self {
acr: Ok(value.acr),
amr: Ok(value.amr),
expires_at: Ok(value.expires_at),
ext: Ok(value.ext),
id: Ok(value.id),
issued_at: Ok(value.issued_at),
subject: Ok(value.subject),
}
}
}
#[derive(Clone, Debug)]
pub struct TokenBundle {
access_token: ::std::result::Result<super::TokenBundleAccessToken, ::std::string::String>,
expires_in: ::std::result::Result<::std::num::NonZeroU64, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
refresh_expires_in: ::std::result::Result<
::std::option::Option<::std::num::NonZeroU64>,
::std::string::String,
>,
refresh_token: ::std::result::Result<
::std::option::Option<super::TokenBundleRefreshToken>,
::std::string::String,
>,
scope: ::std::result::Result<
::std::vec::Vec<super::TokenBundleScopeItem>,
::std::string::String,
>,
token_type: ::std::result::Result<super::TokenBundleTokenType, ::std::string::String>,
}
impl ::std::default::Default for TokenBundle {
fn default() -> Self {
Self {
access_token: Err("no value supplied for access_token".to_string()),
expires_in: Err("no value supplied for expires_in".to_string()),
ext: Ok(Default::default()),
refresh_expires_in: Ok(Default::default()),
refresh_token: Ok(Default::default()),
scope: Ok(Default::default()),
token_type: Err("no value supplied for token_type".to_string()),
}
}
}
impl TokenBundle {
pub fn access_token<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::TokenBundleAccessToken>,
T::Error: ::std::fmt::Display,
{
self.access_token = value
.try_into()
.map_err(|e| format!("error converting supplied value for access_token: {e}"));
self
}
pub fn expires_in<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::num::NonZeroU64>,
T::Error: ::std::fmt::Display,
{
self.expires_in = value
.try_into()
.map_err(|e| format!("error converting supplied value for expires_in: {e}"));
self
}
pub fn ext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Ext>>,
T::Error: ::std::fmt::Display,
{
self.ext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ext: {e}"));
self
}
pub fn refresh_expires_in<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::num::NonZeroU64>>,
T::Error: ::std::fmt::Display,
{
self.refresh_expires_in = value.try_into().map_err(|e| {
format!("error converting supplied value for refresh_expires_in: {e}")
});
self
}
pub fn refresh_token<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::TokenBundleRefreshToken>>,
T::Error: ::std::fmt::Display,
{
self.refresh_token = value
.try_into()
.map_err(|e| format!("error converting supplied value for refresh_token: {e}"));
self
}
pub fn scope<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::TokenBundleScopeItem>>,
T::Error: ::std::fmt::Display,
{
self.scope = value
.try_into()
.map_err(|e| format!("error converting supplied value for scope: {e}"));
self
}
pub fn token_type<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::TokenBundleTokenType>,
T::Error: ::std::fmt::Display,
{
self.token_type = value
.try_into()
.map_err(|e| format!("error converting supplied value for token_type: {e}"));
self
}
}
impl ::std::convert::TryFrom<TokenBundle> for super::TokenBundle {
type Error = super::error::ConversionError;
fn try_from(
value: TokenBundle,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
access_token: value.access_token?,
expires_in: value.expires_in?,
ext: value.ext?,
refresh_expires_in: value.refresh_expires_in?,
refresh_token: value.refresh_token?,
scope: value.scope?,
token_type: value.token_type?,
})
}
}
impl ::std::convert::From<super::TokenBundle> for TokenBundle {
fn from(value: super::TokenBundle) -> Self {
Self {
access_token: Ok(value.access_token),
expires_in: Ok(value.expires_in),
ext: Ok(value.ext),
refresh_expires_in: Ok(value.refresh_expires_in),
refresh_token: Ok(value.refresh_token),
scope: Ok(value.scope),
token_type: Ok(value.token_type),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/auth/refresh/0.1";
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"Ext\":{\"additionalProperties\":true,\"description\":\"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\"minProperties\":1,\"propertyNames\":{\"pattern\":\"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"},\"title\":\"Ext\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"description\":\"Issued by the auth service when the presented refresh token is valid. Carried in a Trust Task document whose type is https://trusttasks.org/spec/auth/refresh/0.1#response.\",\"properties\":{\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"},\"session\":{\"$ref\":\"#/$defs/Session\",\"description\":\"Optional session snapshot. Consumers SHOULD include it so the producer can refresh client-side state (acr changes after step-up, scope changes after policy edits) without a separate whoami call.\"},\"tokens\":{\"$ref\":\"#/$defs/TokenBundle\",\"description\":\"New access token. If the consumer's policy rotates refresh tokens on each use, a new refreshToken is included; otherwise the producer continues using the previously-issued one.\"}},\"required\":[\"tokens\"],\"title\":\"Auth Refresh — response payload\",\"type\":\"object\"},\"Session\":{\"$anchor\":\"session\",\"additionalProperties\":false,\"description\":\"A logical authentication context bound to a subject. Producers and consumers exchange Session-shaped data in challenge issuance, authentication responses, and introspection (whoami).\",\"properties\":{\"acr\":{\"description\":\"Authentication Context Class Reference per [OIDC Core §2]. Profiles define their own values; the recommended set is \\\"aal1\\\" (single-factor DID auth), \\\"aal2\\\" (a second possession-or-biometric factor confirmed), and \\\"aal3\\\" (hardware-bound second factor).\",\"type\":\"string\"},\"amr\":{\"description\":\"Authentication Methods References per [RFC 8176]. Typical values: \\\"did\\\" (challenge-response), \\\"passkey\\\" (WebAuthn), \\\"vta\\\" (verifiable-trust agent approval). Multi-factor sessions list every method used.\",\"items\":{\"minLength\":1,\"type\":\"string\"},\"minItems\":1,\"type\":\"array\"},\"expiresAt\":{\"description\":\"ISO-8601 timestamp when the session ceases to be valid. Producers SHOULD refresh before this time; consumers MUST reject after.\",\"format\":\"date-time\",\"type\":\"string\"},\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"},\"id\":{\"description\":\"Opaque, server-chosen session identifier. Stable for the lifetime of the session. Consumers MUST treat the value as opaque; no structure is implied.\",\"minLength\":1,\"type\":\"string\"},\"issuedAt\":{\"description\":\"ISO-8601 timestamp when the session was created.\",\"format\":\"date-time\",\"type\":\"string\"},\"subject\":{\"description\":\"The authenticated party's VID (typically a DID URL).\",\"minLength\":1,\"type\":\"string\"}},\"required\":[\"id\",\"subject\",\"issuedAt\",\"expiresAt\"],\"title\":\"Session\",\"type\":\"object\"},\"TokenBundle\":{\"$anchor\":\"tokenBundle\",\"additionalProperties\":false,\"description\":\"An access token (typically short-lived JWT) paired with an optional refresh token (typically long-lived opaque string). The shapes follow OAuth 2.0 (RFC 6749 §5.1) conventions but are not coupled to any particular OAuth profile.\",\"properties\":{\"accessToken\":{\"description\":\"Bearer-style access token. Consumers presenting this token to downstream services prove the holder of the original session. Format is consumer-defined — JWT is common, but opaque strings are also valid.\",\"minLength\":1,\"type\":\"string\"},\"expiresIn\":{\"description\":\"Seconds from issuance until the access token expires.\",\"minimum\":1,\"type\":\"integer\"},\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"},\"refreshExpiresIn\":{\"description\":\"Seconds from issuance until the refresh token expires, when one was issued.\",\"minimum\":1,\"type\":\"integer\"},\"refreshToken\":{\"description\":\"Long-lived token redeemable via auth/refresh for a new access token. MAY be absent when the issuer does not support refresh.\",\"minLength\":1,\"type\":\"string\"},\"scope\":{\"description\":\"Capability tags effective on this token. Format is consumer-defined; the framework imposes no syntax.\",\"items\":{\"minLength\":1,\"type\":\"string\"},\"type\":\"array\"},\"tokenType\":{\"description\":\"Token presentation scheme. Almost always \\\"Bearer\\\"; reserved for future schemes.\",\"minLength\":1,\"type\":\"string\"}},\"required\":[\"accessToken\",\"tokenType\",\"expiresIn\"],\"title\":\"TokenBundle\",\"type\":\"object\"}},\"$id\":\"https://trusttasks.org/spec/auth/refresh/0.1\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"additionalProperties\":false,\"description\":\"Exchange a refresh token for a new access token (and optionally a new refresh token).\",\"properties\":{\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"},\"refreshToken\":{\"description\":\"The refresh token previously issued in a TokenBundle. Consumers verify it server-side; producers treat it as opaque.\",\"minLength\":1,\"type\":\"string\"},\"scope\":{\"description\":\"Optional capability tags requested on the new access token. MAY be narrower than the original session's scope; consumers MUST NOT widen scope on refresh.\",\"items\":{\"minLength\":1,\"type\":\"string\"},\"type\":\"array\"}},\"required\":[\"refreshToken\"],\"title\":\"Auth — Refresh\",\"type\":\"object\"}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/auth/refresh/0.1#response";
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"Ext\":{\"additionalProperties\":true,\"description\":\"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\"minProperties\":1,\"propertyNames\":{\"pattern\":\"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"},\"title\":\"Ext\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"description\":\"Issued by the auth service when the presented refresh token is valid. Carried in a Trust Task document whose type is https://trusttasks.org/spec/auth/refresh/0.1#response.\",\"properties\":{\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"},\"session\":{\"$ref\":\"#/$defs/Session\",\"description\":\"Optional session snapshot. Consumers SHOULD include it so the producer can refresh client-side state (acr changes after step-up, scope changes after policy edits) without a separate whoami call.\"},\"tokens\":{\"$ref\":\"#/$defs/TokenBundle\",\"description\":\"New access token. If the consumer's policy rotates refresh tokens on each use, a new refreshToken is included; otherwise the producer continues using the previously-issued one.\"}},\"required\":[\"tokens\"],\"title\":\"Auth Refresh — response payload\",\"type\":\"object\"},\"Session\":{\"$anchor\":\"session\",\"additionalProperties\":false,\"description\":\"A logical authentication context bound to a subject. Producers and consumers exchange Session-shaped data in challenge issuance, authentication responses, and introspection (whoami).\",\"properties\":{\"acr\":{\"description\":\"Authentication Context Class Reference per [OIDC Core §2]. Profiles define their own values; the recommended set is \\\"aal1\\\" (single-factor DID auth), \\\"aal2\\\" (a second possession-or-biometric factor confirmed), and \\\"aal3\\\" (hardware-bound second factor).\",\"type\":\"string\"},\"amr\":{\"description\":\"Authentication Methods References per [RFC 8176]. Typical values: \\\"did\\\" (challenge-response), \\\"passkey\\\" (WebAuthn), \\\"vta\\\" (verifiable-trust agent approval). Multi-factor sessions list every method used.\",\"items\":{\"minLength\":1,\"type\":\"string\"},\"minItems\":1,\"type\":\"array\"},\"expiresAt\":{\"description\":\"ISO-8601 timestamp when the session ceases to be valid. Producers SHOULD refresh before this time; consumers MUST reject after.\",\"format\":\"date-time\",\"type\":\"string\"},\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"},\"id\":{\"description\":\"Opaque, server-chosen session identifier. Stable for the lifetime of the session. Consumers MUST treat the value as opaque; no structure is implied.\",\"minLength\":1,\"type\":\"string\"},\"issuedAt\":{\"description\":\"ISO-8601 timestamp when the session was created.\",\"format\":\"date-time\",\"type\":\"string\"},\"subject\":{\"description\":\"The authenticated party's VID (typically a DID URL).\",\"minLength\":1,\"type\":\"string\"}},\"required\":[\"id\",\"subject\",\"issuedAt\",\"expiresAt\"],\"title\":\"Session\",\"type\":\"object\"},\"TokenBundle\":{\"$anchor\":\"tokenBundle\",\"additionalProperties\":false,\"description\":\"An access token (typically short-lived JWT) paired with an optional refresh token (typically long-lived opaque string). The shapes follow OAuth 2.0 (RFC 6749 §5.1) conventions but are not coupled to any particular OAuth profile.\",\"properties\":{\"accessToken\":{\"description\":\"Bearer-style access token. Consumers presenting this token to downstream services prove the holder of the original session. Format is consumer-defined — JWT is common, but opaque strings are also valid.\",\"minLength\":1,\"type\":\"string\"},\"expiresIn\":{\"description\":\"Seconds from issuance until the access token expires.\",\"minimum\":1,\"type\":\"integer\"},\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"},\"refreshExpiresIn\":{\"description\":\"Seconds from issuance until the refresh token expires, when one was issued.\",\"minimum\":1,\"type\":\"integer\"},\"refreshToken\":{\"description\":\"Long-lived token redeemable via auth/refresh for a new access token. MAY be absent when the issuer does not support refresh.\",\"minLength\":1,\"type\":\"string\"},\"scope\":{\"description\":\"Capability tags effective on this token. Format is consumer-defined; the framework imposes no syntax.\",\"items\":{\"minLength\":1,\"type\":\"string\"},\"type\":\"array\"},\"tokenType\":{\"description\":\"Token presentation scheme. Almost always \\\"Bearer\\\"; reserved for future schemes.\",\"minLength\":1,\"type\":\"string\"}},\"required\":[\"accessToken\",\"tokenType\",\"expiresIn\"],\"title\":\"TokenBundle\",\"type\":\"object\"}},\"$ref\":\"#/$defs/Response\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\"}\n",
);
}
impl crate::RequestPayload for Payload {
type Response = Response;
}
/// The earlier `MAJOR.MINOR` of this slug that this version declares it
/// extends (front matter `extends`, SPEC §5.2 "Declared extension"), or
/// `None`. Only the direct declaration; walk a chain with
/// [`crate::extension::extends_for`].
pub const EXTENDS: Option<&str> = None;
/// The extended error codes this specification declares (SPEC §7.3 item 9,
/// §8.5), in declaration order. Empty when it declares none.
pub const ERROR_CODES: &[crate::DeclaredErrorCode] = &[
error_codes::TOKEN_NOT_FOUND,
error_codes::TOKEN_EXPIRED,
error_codes::TOKEN_REVOKED,
error_codes::SCOPE_WIDENING_REFUSED,
];
/// One constant per extended error code this specification declares
/// (SPEC §7.3 item 9), named for its local part.
///
/// Emit these rather than a string literal: the code is read from the
/// specification, so it cannot name a code the specification never
/// declared.
pub mod error_codes {
/// `auth/refresh:tokenNotFound`
///
/// The refreshToken does not refer to any session the auth service issued.
///
/// Declared `retryable: false`.
pub const TOKEN_NOT_FOUND: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "auth/refresh:tokenNotFound",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `auth/refresh:tokenExpired`
///
/// The refreshToken's refreshExpiresIn has elapsed.
///
/// Declared `retryable: false`.
pub const TOKEN_EXPIRED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "auth/refresh:tokenExpired",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `auth/refresh:tokenRevoked`
///
/// The refreshToken was explicitly invalidated (typically via auth/revoke-session, or by a step-up event that rotated all session refresh tokens).
///
/// Declared `retryable: false`.
pub const TOKEN_REVOKED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "auth/refresh:tokenRevoked",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `auth/refresh:scopeWideningRefused`
///
/// The requested scope exceeds the original session's scope. Refresh MUST NOT broaden privilege.
///
/// Declared `retryable: false`.
/// Declares a `detailsSchema` for the error's `details` member.
pub const SCOPE_WIDENING_REFUSED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "auth/refresh:scopeWideningRefused",
retryable: false,
details_schema: ::core::option::Option::Some(
"{\"additionalProperties\":false,\"properties\":{\"offending\":{\"items\":{\"type\":\"string\"},\"type\":\"array\"}},\"type\":\"object\"}",
),
};
}