//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `policy/evaluate`. 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 policy/evaluate/0.3");
#[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())
}
}
}
///Discriminator: is this consumer a user-driven Companion or a headless Service?
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(tag = "kind", deny_unknown_fields)]
#[non_exhaustive]
pub enum ConsumerKind {
///Companion
#[serde(rename = "companion")]
Companion {
#[serde(rename = "formFactor")]
form_factor: ConsumerKindFormFactor,
},
///Service
#[serde(rename = "service")]
Service {
#[serde(rename = "serviceKind")]
service_kind: ConsumerKindServiceKind,
},
}
///`ConsumerKindFormFactor`
///
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum ConsumerKindFormFactor {
#[serde(rename = "browser")]
Browser,
#[serde(rename = "mobile")]
Mobile,
#[serde(rename = "desktop")]
Desktop,
}
impl ::std::fmt::Display for ConsumerKindFormFactor {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Browser => f.write_str("browser"),
Self::Mobile => f.write_str("mobile"),
Self::Desktop => f.write_str("desktop"),
}
}
}
impl ::std::str::FromStr for ConsumerKindFormFactor {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"browser" => Ok(Self::Browser),
"mobile" => Ok(Self::Mobile),
"desktop" => Ok(Self::Desktop),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ConsumerKindFormFactor {
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 ConsumerKindFormFactor {
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 ConsumerKindFormFactor {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///`ConsumerKindServiceKind`
///
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum ConsumerKindServiceKind {
#[serde(rename = "mediator")]
Mediator,
#[serde(rename = "ai-agent")]
AiAgent,
#[serde(rename = "daemon")]
Daemon,
}
impl ::std::fmt::Display for ConsumerKindServiceKind {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Mediator => f.write_str("mediator"),
Self::AiAgent => f.write_str("ai-agent"),
Self::Daemon => f.write_str("daemon"),
}
}
}
impl ::std::str::FromStr for ConsumerKindServiceKind {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"mediator" => Ok(Self::Mediator),
"ai-agent" => Ok(Self::AiAgent),
"daemon" => Ok(Self::Daemon),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ConsumerKindServiceKind {
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 ConsumerKindServiceKind {
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 ConsumerKindServiceKind {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///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())
})
}
}
///Dry-run a policy decision against a synthetic PolicyInput. Returns the policy decision plus a trace of which policy modules matched and which rules fired. Used by the policy-editor UI to verify changes before save and by admins to diagnose unexpected deny/allow outcomes.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
#[deprecated(note = "superseded by policy/evaluate/0.3")]
pub struct Payload {
///Optional — when supplied, evaluate as if this Rego source were active (e.g. preview a pending upsert). The candidate is layered into the evaluator at the priority specified by `candidatePriority` (default 1000) for this call only.
#[serde(
rename = "candidateModule",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub candidate_module: ::std::option::Option<::std::string::String>,
#[serde(
rename = "candidatePriority",
default = "defaults::default_u64::<i64, 1000>"
)]
pub candidate_priority: i64,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
#[serde(rename = "includeTrace", default)]
pub include_trace: bool,
pub input: PolicyInput,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///`PolicyDecision`
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct PolicyDecision {
pub decision: PolicyDecisionDecision,
///Human-readable explanation for diagnostic display.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub explanation: ::std::option::Option<PolicyDecisionExplanation>,
///When decision == "allow", whether the maintainer should proxy-login or release-for-fill. Default: proxy.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub mode: ::std::option::Option<PolicyDecisionMode>,
#[serde(
rename = "stepUp",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub step_up: ::std::option::Option<PolicyDecisionStepUp>,
///When decision == "allow", maximum lifetime of the issued session blob / released secret.
#[serde(
rename = "ttlSecondsCap",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub ttl_seconds_cap: ::std::option::Option<::std::num::NonZeroU64>,
}
impl PolicyDecision {
pub fn builder() -> builder::PolicyDecision {
Default::default()
}
}
///`PolicyDecisionDecision`
///
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum PolicyDecisionDecision {
#[serde(rename = "allow")]
Allow,
#[serde(rename = "deny")]
Deny,
#[serde(rename = "require_step_up")]
RequireStepUp,
}
impl ::std::fmt::Display for PolicyDecisionDecision {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Allow => f.write_str("allow"),
Self::Deny => f.write_str("deny"),
Self::RequireStepUp => f.write_str("require_step_up"),
}
}
}
impl ::std::str::FromStr for PolicyDecisionDecision {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"allow" => Ok(Self::Allow),
"deny" => Ok(Self::Deny),
"require_step_up" => Ok(Self::RequireStepUp),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for PolicyDecisionDecision {
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 PolicyDecisionDecision {
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 PolicyDecisionDecision {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Human-readable explanation for diagnostic display.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PolicyDecisionExplanation(::std::string::String);
impl ::std::ops::Deref for PolicyDecisionExplanation {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PolicyDecisionExplanation> for ::std::string::String {
fn from(value: PolicyDecisionExplanation) -> Self {
value.0
}
}
impl ::std::str::FromStr for PolicyDecisionExplanation {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 1024usize {
return Err("longer than 1024 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PolicyDecisionExplanation {
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 PolicyDecisionExplanation {
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 PolicyDecisionExplanation {
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 PolicyDecisionExplanation {
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())
})
}
}
///When decision == "allow", whether the maintainer should proxy-login or release-for-fill. Default: proxy.
///
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum PolicyDecisionMode {
#[serde(rename = "proxy")]
Proxy,
#[serde(rename = "fill")]
Fill,
}
impl ::std::fmt::Display for PolicyDecisionMode {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Proxy => f.write_str("proxy"),
Self::Fill => f.write_str("fill"),
}
}
}
impl ::std::str::FromStr for PolicyDecisionMode {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"proxy" => Ok(Self::Proxy),
"fill" => Ok(Self::Fill),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for PolicyDecisionMode {
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 PolicyDecisionMode {
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 PolicyDecisionMode {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///When decision == "require_step_up", which method to demand.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct PolicyDecisionStepUp {
pub method: PolicyDecisionStepUpMethod,
#[serde(
rename = "ttlSeconds",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub ttl_seconds: ::std::option::Option<::std::num::NonZeroU64>,
}
impl PolicyDecisionStepUp {
pub fn builder() -> builder::PolicyDecisionStepUp {
Default::default()
}
}
///`PolicyDecisionStepUpMethod`
///
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum PolicyDecisionStepUpMethod {
#[serde(rename = "webauthn-uv")]
WebauthnUv,
#[serde(rename = "push-approval")]
PushApproval,
#[serde(rename = "totp")]
Totp,
}
impl ::std::fmt::Display for PolicyDecisionStepUpMethod {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::WebauthnUv => f.write_str("webauthn-uv"),
Self::PushApproval => f.write_str("push-approval"),
Self::Totp => f.write_str("totp"),
}
}
}
impl ::std::str::FromStr for PolicyDecisionStepUpMethod {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"webauthn-uv" => Ok(Self::WebauthnUv),
"push-approval" => Ok(Self::PushApproval),
"totp" => Ok(Self::Totp),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for PolicyDecisionStepUpMethod {
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 PolicyDecisionStepUpMethod {
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 PolicyDecisionStepUpMethod {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///The structured input fed to a policy evaluator on every vault/proxy-login, vault/release, and policy/evaluate call.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct PolicyInput {
pub consumer: PolicyInputConsumer,
#[serde(rename = "contextId")]
pub context_id: PolicyInputContextId,
pub request: PolicyInputRequest,
pub site: SiteTarget,
}
impl PolicyInput {
pub fn builder() -> builder::PolicyInput {
Default::default()
}
}
///`PolicyInputConsumer`
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct PolicyInputConsumer {
#[serde(
rename = "deviceId",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub device_id: ::std::option::Option<::std::string::String>,
pub did: ::std::string::String,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub kind: ::std::option::Option<ConsumerKind>,
#[serde(
rename = "lastUserVerificationAt",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub last_user_verification_at: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
#[serde(
rename = "networkClass",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub network_class: ::std::option::Option<PolicyInputConsumerNetworkClass>,
}
impl PolicyInputConsumer {
pub fn builder() -> builder::PolicyInputConsumer {
Default::default()
}
}
///`PolicyInputConsumerNetworkClass`
///
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum PolicyInputConsumerNetworkClass {
#[serde(rename = "unknown")]
Unknown,
#[serde(rename = "home")]
Home,
#[serde(rename = "corp")]
Corp,
#[serde(rename = "public")]
Public,
#[serde(rename = "vpn")]
Vpn,
}
impl ::std::fmt::Display for PolicyInputConsumerNetworkClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Unknown => f.write_str("unknown"),
Self::Home => f.write_str("home"),
Self::Corp => f.write_str("corp"),
Self::Public => f.write_str("public"),
Self::Vpn => f.write_str("vpn"),
}
}
}
impl ::std::str::FromStr for PolicyInputConsumerNetworkClass {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"unknown" => Ok(Self::Unknown),
"home" => Ok(Self::Home),
"corp" => Ok(Self::Corp),
"public" => Ok(Self::Public),
"vpn" => Ok(Self::Vpn),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for PolicyInputConsumerNetworkClass {
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 PolicyInputConsumerNetworkClass {
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 PolicyInputConsumerNetworkClass {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///`PolicyInputContextId`
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PolicyInputContextId(::std::string::String);
impl ::std::ops::Deref for PolicyInputContextId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PolicyInputContextId> for ::std::string::String {
fn from(value: PolicyInputContextId) -> Self {
value.0
}
}
impl ::std::str::FromStr for PolicyInputContextId {
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 PolicyInputContextId {
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 PolicyInputContextId {
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 PolicyInputContextId {
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 PolicyInputContextId {
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())
})
}
}
///`PolicyInputRequest`
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct PolicyInputRequest {
pub kind: PolicyInputRequestKind,
}
impl PolicyInputRequest {
pub fn builder() -> builder::PolicyInputRequest {
Default::default()
}
}
///`PolicyInputRequestKind`
///
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum PolicyInputRequestKind {
#[serde(rename = "proxy_login")]
ProxyLogin,
#[serde(rename = "release")]
Release,
#[serde(rename = "step_up_response")]
StepUpResponse,
}
impl ::std::fmt::Display for PolicyInputRequestKind {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::ProxyLogin => f.write_str("proxy_login"),
Self::Release => f.write_str("release"),
Self::StepUpResponse => f.write_str("step_up_response"),
}
}
}
impl ::std::str::FromStr for PolicyInputRequestKind {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"proxy_login" => Ok(Self::ProxyLogin),
"release" => Ok(Self::Release),
"step_up_response" => Ok(Self::StepUpResponse),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for PolicyInputRequestKind {
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 PolicyInputRequestKind {
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 PolicyInputRequestKind {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///`Response`
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
#[deprecated(note = "superseded by policy/evaluate/0.3")]
pub struct Response {
pub decision: PolicyDecision,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///Ids (or `candidate` for the dry-run module) of the policies that returned a non-null decision, in evaluation order. The first is the winning policy.
#[serde(
rename = "matchedPolicies",
default,
skip_serializing_if = "::std::vec::Vec::is_empty"
)]
pub matched_policies: ::std::vec::Vec<::std::string::String>,
///Rego evaluator trace lines when `includeTrace: true`. Maintainer-defined format; primarily for human debugging.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub trace: ::std::vec::Vec<ResponseTraceItem>,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///`ResponseTraceItem`
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseTraceItem(::std::string::String);
impl ::std::ops::Deref for ResponseTraceItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseTraceItem> for ::std::string::String {
fn from(value: ResponseTraceItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseTraceItem {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 1024usize {
return Err("longer than 1024 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ResponseTraceItem {
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 ResponseTraceItem {
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 ResponseTraceItem {
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 ResponseTraceItem {
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())
})
}
}
///A single binding target for a vault entry. Tagged union over the discriminator `kind`. A VaultEntry's `targets` array MAY mix any number of these.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(tag = "kind", deny_unknown_fields)]
#[non_exhaustive]
pub enum SiteTarget {
///WebOrigin
#[serde(rename = "web-origin")]
WebOrigin {
///Web origin per RFC 6454 (scheme + host + optional port), e.g. "https://github.com". Compared by exact string equality after canonicalisation (lowercase host, default port elided). Consumers wanting subdomain coverage SHOULD add multiple targets, not encode a wildcard.
origin: ::std::string::String,
},
///Did
#[serde(rename = "did")]
Did {
///DID identifying the relying party (e.g. did:web:rp.example). The vault maintainer is responsible for any DID resolution required to act on this entry.
did: SiteTargetDid,
},
///IosApp
#[serde(rename = "ios-app")]
IosApp {
///iOS bundle identifier in reverse-DNS form (e.g. "com.github.stwalkerster.codehub"). Compared by exact string equality. Matches when an iOS Companion identifies the requesting app via its bundle id (typically via the OS Credential Manager integration).
#[serde(rename = "bundleId")]
bundle_id: SiteTargetBundleId,
///Optional Apple Developer Team identifier (10-character alphanumeric). When supplied, the maintainer SHOULD also verify the team id of the requesting app before matching — defense in depth against bundle-id squatting on jailbroken devices.
#[serde(
rename = "teamId",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
team_id: ::std::option::Option<SiteTargetTeamId>,
},
///AndroidApp
#[serde(rename = "android-app")]
AndroidApp {
///Android package name in reverse-DNS form (e.g. "com.github.android").
#[serde(rename = "packageName")]
package_name: SiteTargetPackageName,
///SHA-256 fingerprints of the app's signing certificates, in colon-separated hex (the format `apksigner` and the Play Console emit). At least one fingerprint MUST be present. The maintainer matches when ANY of the provided fingerprints matches the requesting app's signature — this supports apps signed by multiple keys (e.g. during certificate rotation via Play App Signing).
#[serde(rename = "sha256CertFingerprints")]
sha256_cert_fingerprints: Vec<SiteTargetSha256CertFingerprintsItem>,
},
}
///iOS bundle identifier in reverse-DNS form (e.g. "com.github.stwalkerster.codehub"). Compared by exact string equality. Matches when an iOS Companion identifies the requesting app via its bundle id (typically via the OS Credential Manager integration).
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct SiteTargetBundleId(::std::string::String);
impl ::std::ops::Deref for SiteTargetBundleId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<SiteTargetBundleId> for ::std::string::String {
fn from(value: SiteTargetBundleId) -> Self {
value.0
}
}
impl ::std::str::FromStr for SiteTargetBundleId {
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());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| ::regress::Regex::new("^[A-Za-z0-9.-]+$").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[A-Za-z0-9.-]+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for SiteTargetBundleId {
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 SiteTargetBundleId {
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 SiteTargetBundleId {
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 SiteTargetBundleId {
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())
})
}
}
///DID identifying the relying party (e.g. did:web:rp.example). The vault maintainer is responsible for any DID resolution required to act on this entry.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct SiteTargetDid(::std::string::String);
impl ::std::ops::Deref for SiteTargetDid {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<SiteTargetDid> for ::std::string::String {
fn from(value: SiteTargetDid) -> Self {
value.0
}
}
impl ::std::str::FromStr for SiteTargetDid {
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 SiteTargetDid {
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 SiteTargetDid {
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 SiteTargetDid {
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 SiteTargetDid {
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())
})
}
}
///Android package name in reverse-DNS form (e.g. "com.github.android").
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct SiteTargetPackageName(::std::string::String);
impl ::std::ops::Deref for SiteTargetPackageName {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<SiteTargetPackageName> for ::std::string::String {
fn from(value: SiteTargetPackageName) -> Self {
value.0
}
}
impl ::std::str::FromStr for SiteTargetPackageName {
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());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^[A-Za-z][A-Za-z0-9_]*(\\.[A-Za-z][A-Za-z0-9_]*)+$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err(
"doesn't match pattern \"^[A-Za-z][A-Za-z0-9_]*(\\.[A-Za-z][A-Za-z0-9_]*)+$\""
.into(),
);
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for SiteTargetPackageName {
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 SiteTargetPackageName {
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 SiteTargetPackageName {
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 SiteTargetPackageName {
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())
})
}
}
///`SiteTargetSha256CertFingerprintsItem`
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct SiteTargetSha256CertFingerprintsItem(::std::string::String);
impl ::std::ops::Deref for SiteTargetSha256CertFingerprintsItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<SiteTargetSha256CertFingerprintsItem> for ::std::string::String {
fn from(value: SiteTargetSha256CertFingerprintsItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for SiteTargetSha256CertFingerprintsItem {
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("^[0-9A-F]{2}(:[0-9A-F]{2}){31}$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[0-9A-F]{2}(:[0-9A-F]{2}){31}$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for SiteTargetSha256CertFingerprintsItem {
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 SiteTargetSha256CertFingerprintsItem {
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 SiteTargetSha256CertFingerprintsItem {
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 SiteTargetSha256CertFingerprintsItem {
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())
})
}
}
///Optional Apple Developer Team identifier (10-character alphanumeric). When supplied, the maintainer SHOULD also verify the team id of the requesting app before matching — defense in depth against bundle-id squatting on jailbroken devices.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct SiteTargetTeamId(::std::string::String);
impl ::std::ops::Deref for SiteTargetTeamId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<SiteTargetTeamId> for ::std::string::String {
fn from(value: SiteTargetTeamId) -> Self {
value.0
}
}
impl ::std::str::FromStr for SiteTargetTeamId {
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());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| ::regress::Regex::new("^[A-Z0-9]+$").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[A-Z0-9]+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for SiteTargetTeamId {
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 SiteTargetTeamId {
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 SiteTargetTeamId {
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 SiteTargetTeamId {
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 {
candidate_module: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
candidate_priority: ::std::result::Result<i64, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
include_trace: ::std::result::Result<bool, ::std::string::String>,
input: ::std::result::Result<super::PolicyInput, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
candidate_module: Ok(Default::default()),
candidate_priority: Ok(super::defaults::default_u64::<i64, 1000>()),
ext: Ok(Default::default()),
include_trace: Ok(Default::default()),
input: Err("no value supplied for input".to_string()),
}
}
}
impl Payload {
pub fn candidate_module<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.candidate_module = value
.try_into()
.map_err(|e| format!("error converting supplied value for candidate_module: {e}"));
self
}
pub fn candidate_priority<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<i64>,
T::Error: ::std::fmt::Display,
{
self.candidate_priority = value.try_into().map_err(|e| {
format!("error converting supplied value for candidate_priority: {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 include_trace<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.include_trace = value
.try_into()
.map_err(|e| format!("error converting supplied value for include_trace: {e}"));
self
}
pub fn input<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PolicyInput>,
T::Error: ::std::fmt::Display,
{
self.input = value
.try_into()
.map_err(|e| format!("error converting supplied value for input: {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 {
candidate_module: value.candidate_module?,
candidate_priority: value.candidate_priority?,
ext: value.ext?,
include_trace: value.include_trace?,
input: value.input?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
candidate_module: Ok(value.candidate_module),
candidate_priority: Ok(value.candidate_priority),
ext: Ok(value.ext),
include_trace: Ok(value.include_trace),
input: Ok(value.input),
}
}
}
#[derive(Clone, Debug)]
pub struct PolicyDecision {
decision: ::std::result::Result<super::PolicyDecisionDecision, ::std::string::String>,
explanation: ::std::result::Result<
::std::option::Option<super::PolicyDecisionExplanation>,
::std::string::String,
>,
mode: ::std::result::Result<
::std::option::Option<super::PolicyDecisionMode>,
::std::string::String,
>,
step_up: ::std::result::Result<
::std::option::Option<super::PolicyDecisionStepUp>,
::std::string::String,
>,
ttl_seconds_cap: ::std::result::Result<
::std::option::Option<::std::num::NonZeroU64>,
::std::string::String,
>,
}
impl ::std::default::Default for PolicyDecision {
fn default() -> Self {
Self {
decision: Err("no value supplied for decision".to_string()),
explanation: Ok(Default::default()),
mode: Ok(Default::default()),
step_up: Ok(Default::default()),
ttl_seconds_cap: Ok(Default::default()),
}
}
}
impl PolicyDecision {
pub fn decision<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PolicyDecisionDecision>,
T::Error: ::std::fmt::Display,
{
self.decision = value
.try_into()
.map_err(|e| format!("error converting supplied value for decision: {e}"));
self
}
pub fn explanation<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PolicyDecisionExplanation>>,
T::Error: ::std::fmt::Display,
{
self.explanation = value
.try_into()
.map_err(|e| format!("error converting supplied value for explanation: {e}"));
self
}
pub fn mode<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PolicyDecisionMode>>,
T::Error: ::std::fmt::Display,
{
self.mode = value
.try_into()
.map_err(|e| format!("error converting supplied value for mode: {e}"));
self
}
pub fn step_up<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PolicyDecisionStepUp>>,
T::Error: ::std::fmt::Display,
{
self.step_up = value
.try_into()
.map_err(|e| format!("error converting supplied value for step_up: {e}"));
self
}
pub fn ttl_seconds_cap<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::num::NonZeroU64>>,
T::Error: ::std::fmt::Display,
{
self.ttl_seconds_cap = value
.try_into()
.map_err(|e| format!("error converting supplied value for ttl_seconds_cap: {e}"));
self
}
}
impl ::std::convert::TryFrom<PolicyDecision> for super::PolicyDecision {
type Error = super::error::ConversionError;
fn try_from(
value: PolicyDecision,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
decision: value.decision?,
explanation: value.explanation?,
mode: value.mode?,
step_up: value.step_up?,
ttl_seconds_cap: value.ttl_seconds_cap?,
})
}
}
impl ::std::convert::From<super::PolicyDecision> for PolicyDecision {
fn from(value: super::PolicyDecision) -> Self {
Self {
decision: Ok(value.decision),
explanation: Ok(value.explanation),
mode: Ok(value.mode),
step_up: Ok(value.step_up),
ttl_seconds_cap: Ok(value.ttl_seconds_cap),
}
}
}
#[derive(Clone, Debug)]
pub struct PolicyDecisionStepUp {
method: ::std::result::Result<super::PolicyDecisionStepUpMethod, ::std::string::String>,
ttl_seconds: ::std::result::Result<
::std::option::Option<::std::num::NonZeroU64>,
::std::string::String,
>,
}
impl ::std::default::Default for PolicyDecisionStepUp {
fn default() -> Self {
Self {
method: Err("no value supplied for method".to_string()),
ttl_seconds: Ok(Default::default()),
}
}
}
impl PolicyDecisionStepUp {
pub fn method<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PolicyDecisionStepUpMethod>,
T::Error: ::std::fmt::Display,
{
self.method = value
.try_into()
.map_err(|e| format!("error converting supplied value for method: {e}"));
self
}
pub fn ttl_seconds<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::num::NonZeroU64>>,
T::Error: ::std::fmt::Display,
{
self.ttl_seconds = value
.try_into()
.map_err(|e| format!("error converting supplied value for ttl_seconds: {e}"));
self
}
}
impl ::std::convert::TryFrom<PolicyDecisionStepUp> for super::PolicyDecisionStepUp {
type Error = super::error::ConversionError;
fn try_from(
value: PolicyDecisionStepUp,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
method: value.method?,
ttl_seconds: value.ttl_seconds?,
})
}
}
impl ::std::convert::From<super::PolicyDecisionStepUp> for PolicyDecisionStepUp {
fn from(value: super::PolicyDecisionStepUp) -> Self {
Self {
method: Ok(value.method),
ttl_seconds: Ok(value.ttl_seconds),
}
}
}
#[derive(Clone, Debug)]
pub struct PolicyInput {
consumer: ::std::result::Result<super::PolicyInputConsumer, ::std::string::String>,
context_id: ::std::result::Result<super::PolicyInputContextId, ::std::string::String>,
request: ::std::result::Result<super::PolicyInputRequest, ::std::string::String>,
site: ::std::result::Result<super::SiteTarget, ::std::string::String>,
}
impl ::std::default::Default for PolicyInput {
fn default() -> Self {
Self {
consumer: Err("no value supplied for consumer".to_string()),
context_id: Err("no value supplied for context_id".to_string()),
request: Err("no value supplied for request".to_string()),
site: Err("no value supplied for site".to_string()),
}
}
}
impl PolicyInput {
pub fn consumer<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PolicyInputConsumer>,
T::Error: ::std::fmt::Display,
{
self.consumer = value
.try_into()
.map_err(|e| format!("error converting supplied value for consumer: {e}"));
self
}
pub fn context_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PolicyInputContextId>,
T::Error: ::std::fmt::Display,
{
self.context_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for context_id: {e}"));
self
}
pub fn request<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PolicyInputRequest>,
T::Error: ::std::fmt::Display,
{
self.request = value
.try_into()
.map_err(|e| format!("error converting supplied value for request: {e}"));
self
}
pub fn site<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::SiteTarget>,
T::Error: ::std::fmt::Display,
{
self.site = value
.try_into()
.map_err(|e| format!("error converting supplied value for site: {e}"));
self
}
}
impl ::std::convert::TryFrom<PolicyInput> for super::PolicyInput {
type Error = super::error::ConversionError;
fn try_from(
value: PolicyInput,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
consumer: value.consumer?,
context_id: value.context_id?,
request: value.request?,
site: value.site?,
})
}
}
impl ::std::convert::From<super::PolicyInput> for PolicyInput {
fn from(value: super::PolicyInput) -> Self {
Self {
consumer: Ok(value.consumer),
context_id: Ok(value.context_id),
request: Ok(value.request),
site: Ok(value.site),
}
}
}
#[derive(Clone, Debug)]
pub struct PolicyInputConsumer {
device_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
did: ::std::result::Result<::std::string::String, ::std::string::String>,
kind: ::std::result::Result<
::std::option::Option<super::ConsumerKind>,
::std::string::String,
>,
last_user_verification_at: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
network_class: ::std::result::Result<
::std::option::Option<super::PolicyInputConsumerNetworkClass>,
::std::string::String,
>,
}
impl ::std::default::Default for PolicyInputConsumer {
fn default() -> Self {
Self {
device_id: Ok(Default::default()),
did: Err("no value supplied for did".to_string()),
kind: Ok(Default::default()),
last_user_verification_at: Ok(Default::default()),
network_class: Ok(Default::default()),
}
}
}
impl PolicyInputConsumer {
pub fn device_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.device_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for device_id: {e}"));
self
}
pub fn did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.did = value
.try_into()
.map_err(|e| format!("error converting supplied value for did: {e}"));
self
}
pub fn kind<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ConsumerKind>>,
T::Error: ::std::fmt::Display,
{
self.kind = value
.try_into()
.map_err(|e| format!("error converting supplied value for kind: {e}"));
self
}
pub fn last_user_verification_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
>,
T::Error: ::std::fmt::Display,
{
self.last_user_verification_at = value.try_into().map_err(|e| {
format!("error converting supplied value for last_user_verification_at: {e}")
});
self
}
pub fn network_class<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::PolicyInputConsumerNetworkClass>,
>,
T::Error: ::std::fmt::Display,
{
self.network_class = value
.try_into()
.map_err(|e| format!("error converting supplied value for network_class: {e}"));
self
}
}
impl ::std::convert::TryFrom<PolicyInputConsumer> for super::PolicyInputConsumer {
type Error = super::error::ConversionError;
fn try_from(
value: PolicyInputConsumer,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
device_id: value.device_id?,
did: value.did?,
kind: value.kind?,
last_user_verification_at: value.last_user_verification_at?,
network_class: value.network_class?,
})
}
}
impl ::std::convert::From<super::PolicyInputConsumer> for PolicyInputConsumer {
fn from(value: super::PolicyInputConsumer) -> Self {
Self {
device_id: Ok(value.device_id),
did: Ok(value.did),
kind: Ok(value.kind),
last_user_verification_at: Ok(value.last_user_verification_at),
network_class: Ok(value.network_class),
}
}
}
#[derive(Clone, Debug)]
pub struct PolicyInputRequest {
kind: ::std::result::Result<super::PolicyInputRequestKind, ::std::string::String>,
}
impl ::std::default::Default for PolicyInputRequest {
fn default() -> Self {
Self {
kind: Err("no value supplied for kind".to_string()),
}
}
}
impl PolicyInputRequest {
pub fn kind<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PolicyInputRequestKind>,
T::Error: ::std::fmt::Display,
{
self.kind = value
.try_into()
.map_err(|e| format!("error converting supplied value for kind: {e}"));
self
}
}
impl ::std::convert::TryFrom<PolicyInputRequest> for super::PolicyInputRequest {
type Error = super::error::ConversionError;
fn try_from(
value: PolicyInputRequest,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self { kind: value.kind? })
}
}
impl ::std::convert::From<super::PolicyInputRequest> for PolicyInputRequest {
fn from(value: super::PolicyInputRequest) -> Self {
Self {
kind: Ok(value.kind),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
decision: ::std::result::Result<super::PolicyDecision, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
matched_policies:
::std::result::Result<::std::vec::Vec<::std::string::String>, ::std::string::String>,
trace:
::std::result::Result<::std::vec::Vec<super::ResponseTraceItem>, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
decision: Err("no value supplied for decision".to_string()),
ext: Ok(Default::default()),
matched_policies: Ok(Default::default()),
trace: Ok(Default::default()),
}
}
}
impl Response {
pub fn decision<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PolicyDecision>,
T::Error: ::std::fmt::Display,
{
self.decision = value
.try_into()
.map_err(|e| format!("error converting supplied value for decision: {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 matched_policies<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.matched_policies = value
.try_into()
.map_err(|e| format!("error converting supplied value for matched_policies: {e}"));
self
}
pub fn trace<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::ResponseTraceItem>>,
T::Error: ::std::fmt::Display,
{
self.trace = value
.try_into()
.map_err(|e| format!("error converting supplied value for trace: {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 {
decision: value.decision?,
ext: value.ext?,
matched_policies: value.matched_policies?,
trace: value.trace?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
decision: Ok(value.decision),
ext: Ok(value.ext),
matched_policies: Ok(value.matched_policies),
trace: Ok(value.trace),
}
}
}
}
/// Generation of default values for serde.
pub mod defaults {
pub(super) fn default_u64<T, const V: u64>() -> T
where
T: ::std::convert::TryFrom<u64>,
<T as ::std::convert::TryFrom<u64>>::Error: ::std::fmt::Debug,
{
T::try_from(V).unwrap()
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/policy/evaluate/0.1";
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"ConsumerKind\":{\"description\":\"Discriminator: is this consumer a user-driven Companion or a headless Service?\",\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"formFactor\":{\"enum\":[\"browser\",\"mobile\",\"desktop\"],\"type\":\"string\"},\"kind\":{\"const\":\"companion\"}},\"required\":[\"kind\",\"formFactor\"],\"title\":\"Companion\",\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"kind\":{\"const\":\"service\"},\"serviceKind\":{\"enum\":[\"mediator\",\"ai-agent\",\"daemon\"],\"type\":\"string\"}},\"required\":[\"kind\",\"serviceKind\"],\"title\":\"Service\",\"type\":\"object\"}],\"title\":\"ConsumerKind\"},\"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\"},\"PolicyDecision\":{\"additionalProperties\":false,\"properties\":{\"decision\":{\"enum\":[\"allow\",\"deny\",\"require_step_up\"],\"type\":\"string\"},\"explanation\":{\"description\":\"Human-readable explanation for diagnostic display.\",\"maxLength\":1024,\"type\":\"string\"},\"mode\":{\"description\":\"When decision == \\\"allow\\\", whether the maintainer should proxy-login or release-for-fill. Default: proxy.\",\"enum\":[\"proxy\",\"fill\"],\"type\":\"string\"},\"stepUp\":{\"additionalProperties\":false,\"description\":\"When decision == \\\"require_step_up\\\", which method to demand.\",\"properties\":{\"method\":{\"enum\":[\"webauthn-uv\",\"push-approval\",\"totp\"],\"type\":\"string\"},\"ttlSeconds\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"method\"],\"type\":\"object\"},\"ttlSecondsCap\":{\"description\":\"When decision == \\\"allow\\\", maximum lifetime of the issued session blob / released secret.\",\"maximum\":86400,\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"decision\"],\"title\":\"PolicyDecision\",\"type\":\"object\"},\"PolicyInput\":{\"additionalProperties\":false,\"description\":\"The structured input fed to a policy evaluator on every vault/proxy-login, vault/release, and policy/evaluate call.\",\"properties\":{\"consumer\":{\"additionalProperties\":false,\"properties\":{\"deviceId\":{\"type\":\"string\"},\"did\":{\"type\":\"string\"},\"kind\":{\"$ref\":\"#/$defs/ConsumerKind\"},\"lastUserVerificationAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"networkClass\":{\"enum\":[\"unknown\",\"home\",\"corp\",\"public\",\"vpn\"],\"type\":\"string\"}},\"required\":[\"did\"],\"type\":\"object\"},\"contextId\":{\"minLength\":1,\"type\":\"string\"},\"request\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"proxy_login\",\"release\",\"step_up_response\"],\"type\":\"string\"}},\"required\":[\"kind\"],\"type\":\"object\"},\"site\":{\"$ref\":\"#/$defs/SiteTarget\"}},\"required\":[\"request\",\"site\",\"contextId\",\"consumer\"],\"title\":\"PolicyInput\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"properties\":{\"decision\":{\"$ref\":\"#/$defs/PolicyDecision\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"matchedPolicies\":{\"description\":\"Ids (or `candidate` for the dry-run module) of the policies that returned a non-null decision, in evaluation order. The first is the winning policy.\",\"items\":{\"type\":\"string\"},\"type\":\"array\"},\"trace\":{\"description\":\"Rego evaluator trace lines when `includeTrace: true`. Maintainer-defined format; primarily for human debugging.\",\"items\":{\"maxLength\":1024,\"type\":\"string\"},\"type\":\"array\"}},\"required\":[\"decision\"],\"title\":\"Policy Evaluate — response payload\",\"type\":\"object\"},\"SiteTarget\":{\"description\":\"A single binding target for a vault entry. Tagged union over the discriminator `kind`. A VaultEntry's `targets` array MAY mix any number of these.\",\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"const\":\"web-origin\"},\"origin\":{\"description\":\"Web origin per RFC 6454 (scheme + host + optional port), e.g. \\\"https://github.com\\\". Compared by exact string equality after canonicalisation (lowercase host, default port elided). Consumers wanting subdomain coverage SHOULD add multiple targets, not encode a wildcard.\",\"format\":\"uri\",\"type\":\"string\"}},\"required\":[\"kind\",\"origin\"],\"title\":\"WebOrigin\",\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"did\":{\"description\":\"DID identifying the relying party (e.g. did:web:rp.example). The vault maintainer is responsible for any DID resolution required to act on this entry.\",\"minLength\":1,\"type\":\"string\"},\"kind\":{\"const\":\"did\"}},\"required\":[\"kind\",\"did\"],\"title\":\"Did\",\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"bundleId\":{\"description\":\"iOS bundle identifier in reverse-DNS form (e.g. \\\"com.github.stwalkerster.codehub\\\"). Compared by exact string equality. Matches when an iOS Companion identifies the requesting app via its bundle id (typically via the OS Credential Manager integration).\",\"minLength\":1,\"pattern\":\"^[A-Za-z0-9.-]+$\",\"type\":\"string\"},\"kind\":{\"const\":\"ios-app\"},\"teamId\":{\"description\":\"Optional Apple Developer Team identifier (10-character alphanumeric). When supplied, the maintainer SHOULD also verify the team id of the requesting app before matching — defense in depth against bundle-id squatting on jailbroken devices.\",\"minLength\":1,\"pattern\":\"^[A-Z0-9]+$\",\"type\":\"string\"}},\"required\":[\"kind\",\"bundleId\"],\"title\":\"IosApp\",\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"kind\":{\"const\":\"android-app\"},\"packageName\":{\"description\":\"Android package name in reverse-DNS form (e.g. \\\"com.github.android\\\").\",\"minLength\":1,\"pattern\":\"^[A-Za-z][A-Za-z0-9_]*(\\\\.[A-Za-z][A-Za-z0-9_]*)+$\",\"type\":\"string\"},\"sha256CertFingerprints\":{\"description\":\"SHA-256 fingerprints of the app's signing certificates, in colon-separated hex (the format `apksigner` and the Play Console emit). At least one fingerprint MUST be present. The maintainer matches when ANY of the provided fingerprints matches the requesting app's signature — this supports apps signed by multiple keys (e.g. during certificate rotation via Play App Signing).\",\"items\":{\"pattern\":\"^[0-9A-F]{2}(:[0-9A-F]{2}){31}$\",\"type\":\"string\"},\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"kind\",\"packageName\",\"sha256CertFingerprints\"],\"title\":\"AndroidApp\",\"type\":\"object\"}],\"title\":\"SiteTarget\"}},\"$id\":\"https://trusttasks.org/spec/policy/evaluate/0.1\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"additionalProperties\":false,\"description\":\"Dry-run a policy decision against a synthetic PolicyInput. Returns the policy decision plus a trace of which policy modules matched and which rules fired. Used by the policy-editor UI to verify changes before save and by admins to diagnose unexpected deny/allow outcomes.\",\"properties\":{\"candidateModule\":{\"description\":\"Optional — when supplied, evaluate as if this Rego source were active (e.g. preview a pending upsert). The candidate is layered into the evaluator at the priority specified by `candidatePriority` (default 1000) for this call only.\",\"type\":\"string\"},\"candidatePriority\":{\"default\":1000,\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"includeTrace\":{\"default\":false,\"type\":\"boolean\"},\"input\":{\"$ref\":\"#/$defs/PolicyInput\"}},\"required\":[\"input\"],\"title\":\"Policy Evaluate — payload\",\"type\":\"object\"}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/policy/evaluate/0.1#response";
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"ConsumerKind\":{\"description\":\"Discriminator: is this consumer a user-driven Companion or a headless Service?\",\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"formFactor\":{\"enum\":[\"browser\",\"mobile\",\"desktop\"],\"type\":\"string\"},\"kind\":{\"const\":\"companion\"}},\"required\":[\"kind\",\"formFactor\"],\"title\":\"Companion\",\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"kind\":{\"const\":\"service\"},\"serviceKind\":{\"enum\":[\"mediator\",\"ai-agent\",\"daemon\"],\"type\":\"string\"}},\"required\":[\"kind\",\"serviceKind\"],\"title\":\"Service\",\"type\":\"object\"}],\"title\":\"ConsumerKind\"},\"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\"},\"PolicyDecision\":{\"additionalProperties\":false,\"properties\":{\"decision\":{\"enum\":[\"allow\",\"deny\",\"require_step_up\"],\"type\":\"string\"},\"explanation\":{\"description\":\"Human-readable explanation for diagnostic display.\",\"maxLength\":1024,\"type\":\"string\"},\"mode\":{\"description\":\"When decision == \\\"allow\\\", whether the maintainer should proxy-login or release-for-fill. Default: proxy.\",\"enum\":[\"proxy\",\"fill\"],\"type\":\"string\"},\"stepUp\":{\"additionalProperties\":false,\"description\":\"When decision == \\\"require_step_up\\\", which method to demand.\",\"properties\":{\"method\":{\"enum\":[\"webauthn-uv\",\"push-approval\",\"totp\"],\"type\":\"string\"},\"ttlSeconds\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"method\"],\"type\":\"object\"},\"ttlSecondsCap\":{\"description\":\"When decision == \\\"allow\\\", maximum lifetime of the issued session blob / released secret.\",\"maximum\":86400,\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"decision\"],\"title\":\"PolicyDecision\",\"type\":\"object\"},\"PolicyInput\":{\"additionalProperties\":false,\"description\":\"The structured input fed to a policy evaluator on every vault/proxy-login, vault/release, and policy/evaluate call.\",\"properties\":{\"consumer\":{\"additionalProperties\":false,\"properties\":{\"deviceId\":{\"type\":\"string\"},\"did\":{\"type\":\"string\"},\"kind\":{\"$ref\":\"#/$defs/ConsumerKind\"},\"lastUserVerificationAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"networkClass\":{\"enum\":[\"unknown\",\"home\",\"corp\",\"public\",\"vpn\"],\"type\":\"string\"}},\"required\":[\"did\"],\"type\":\"object\"},\"contextId\":{\"minLength\":1,\"type\":\"string\"},\"request\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"proxy_login\",\"release\",\"step_up_response\"],\"type\":\"string\"}},\"required\":[\"kind\"],\"type\":\"object\"},\"site\":{\"$ref\":\"#/$defs/SiteTarget\"}},\"required\":[\"request\",\"site\",\"contextId\",\"consumer\"],\"title\":\"PolicyInput\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"properties\":{\"decision\":{\"$ref\":\"#/$defs/PolicyDecision\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"matchedPolicies\":{\"description\":\"Ids (or `candidate` for the dry-run module) of the policies that returned a non-null decision, in evaluation order. The first is the winning policy.\",\"items\":{\"type\":\"string\"},\"type\":\"array\"},\"trace\":{\"description\":\"Rego evaluator trace lines when `includeTrace: true`. Maintainer-defined format; primarily for human debugging.\",\"items\":{\"maxLength\":1024,\"type\":\"string\"},\"type\":\"array\"}},\"required\":[\"decision\"],\"title\":\"Policy Evaluate — response payload\",\"type\":\"object\"},\"SiteTarget\":{\"description\":\"A single binding target for a vault entry. Tagged union over the discriminator `kind`. A VaultEntry's `targets` array MAY mix any number of these.\",\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"const\":\"web-origin\"},\"origin\":{\"description\":\"Web origin per RFC 6454 (scheme + host + optional port), e.g. \\\"https://github.com\\\". Compared by exact string equality after canonicalisation (lowercase host, default port elided). Consumers wanting subdomain coverage SHOULD add multiple targets, not encode a wildcard.\",\"format\":\"uri\",\"type\":\"string\"}},\"required\":[\"kind\",\"origin\"],\"title\":\"WebOrigin\",\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"did\":{\"description\":\"DID identifying the relying party (e.g. did:web:rp.example). The vault maintainer is responsible for any DID resolution required to act on this entry.\",\"minLength\":1,\"type\":\"string\"},\"kind\":{\"const\":\"did\"}},\"required\":[\"kind\",\"did\"],\"title\":\"Did\",\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"bundleId\":{\"description\":\"iOS bundle identifier in reverse-DNS form (e.g. \\\"com.github.stwalkerster.codehub\\\"). Compared by exact string equality. Matches when an iOS Companion identifies the requesting app via its bundle id (typically via the OS Credential Manager integration).\",\"minLength\":1,\"pattern\":\"^[A-Za-z0-9.-]+$\",\"type\":\"string\"},\"kind\":{\"const\":\"ios-app\"},\"teamId\":{\"description\":\"Optional Apple Developer Team identifier (10-character alphanumeric). When supplied, the maintainer SHOULD also verify the team id of the requesting app before matching — defense in depth against bundle-id squatting on jailbroken devices.\",\"minLength\":1,\"pattern\":\"^[A-Z0-9]+$\",\"type\":\"string\"}},\"required\":[\"kind\",\"bundleId\"],\"title\":\"IosApp\",\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"kind\":{\"const\":\"android-app\"},\"packageName\":{\"description\":\"Android package name in reverse-DNS form (e.g. \\\"com.github.android\\\").\",\"minLength\":1,\"pattern\":\"^[A-Za-z][A-Za-z0-9_]*(\\\\.[A-Za-z][A-Za-z0-9_]*)+$\",\"type\":\"string\"},\"sha256CertFingerprints\":{\"description\":\"SHA-256 fingerprints of the app's signing certificates, in colon-separated hex (the format `apksigner` and the Play Console emit). At least one fingerprint MUST be present. The maintainer matches when ANY of the provided fingerprints matches the requesting app's signature — this supports apps signed by multiple keys (e.g. during certificate rotation via Play App Signing).\",\"items\":{\"pattern\":\"^[0-9A-F]{2}(:[0-9A-F]{2}){31}$\",\"type\":\"string\"},\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"kind\",\"packageName\",\"sha256CertFingerprints\"],\"title\":\"AndroidApp\",\"type\":\"object\"}],\"title\":\"SiteTarget\"}},\"$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::CANDIDATE_REGO_INVALID];
/// 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 {
/// `policy/evaluate:candidateRegoInvalid`
///
/// The supplied `candidateModule` failed parsing.
///
/// Declared `retryable: false`.
/// Declares a `detailsSchema` for the error's `details` member.
pub const CANDIDATE_REGO_INVALID: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "policy/evaluate:candidateRegoInvalid",
retryable: false,
details_schema: ::core::option::Option::Some(
"{\"additionalProperties\":false,\"properties\":{\"column\":{\"minimum\":1,\"type\":\"integer\"},\"line\":{\"minimum\":1,\"type\":\"integer\"},\"message\":{\"type\":\"string\"}},\"type\":\"object\"}",
),
};
}