//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `push/register`. Version: `0.1`.
#[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.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Ext",
/// "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.",
/// "type": "object",
/// "minProperties": 1,
/// "additionalProperties": true,
/// "propertyNames": {
/// "pattern": "^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$"
/// }
///}
/// ```
/// </details>
#[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`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "pattern": "^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$"
///}
/// ```
/// </details>
#[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())
})
}
}
///A device registers its platform push token (APNs / FCM / Web Push) with a push gateway and names the controller VTA permitted to provision its trigger allowlist. The gateway returns an opaque WakeHandle; the raw token is held by the gateway only. See the push wake-up binding (https://trusttasks.org/binding/push/0.1).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/push/register/0.1",
/// "title": "Payload",
/// "description": "A device registers its platform push token (APNs / FCM / Web Push) with a push gateway and names the controller VTA permitted to provision its trigger allowlist. The gateway returns an opaque WakeHandle; the raw token is held by the gateway only. See the push wake-up binding (https://trusttasks.org/binding/push/0.1).",
/// "type": "object",
/// "required": [
/// "controllerVtaDid",
/// "registration"
/// ],
/// "properties": {
/// "controllerVtaDid": {
/// "description": "The DID of the VTA permitted to provision this handle's trigger allowlist (push/provision). The device conveys the resulting handle to this VTA via device/set-wake.",
/// "type": "string",
/// "minLength": 1
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "registration": {
/// "description": "The platform push channel (token). Held by the gateway only — never disclosed to any other party.",
/// "$ref": "#/definitions/PushRegistration"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Payload {
///The DID of the VTA permitted to provision this handle's trigger allowlist (push/provision). The device conveys the resulting handle to this VTA via device/set-wake.
#[serde(rename = "controllerVtaDid")]
pub controller_vta_did: PayloadControllerVtaDid,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///The platform push channel (token). Held by the gateway only — never disclosed to any other party.
pub registration: PushRegistration,
}
///The DID of the VTA permitted to provision this handle's trigger allowlist (push/provision). The device conveys the resulting handle to this VTA via device/set-wake.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The DID of the VTA permitted to provision this handle's trigger allowlist (push/provision). The device conveys the resulting handle to this VTA via device/set-wake.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadControllerVtaDid(::std::string::String);
impl ::std::ops::Deref for PayloadControllerVtaDid {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadControllerVtaDid> for ::std::string::String {
fn from(value: PayloadControllerVtaDid) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadControllerVtaDid {
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 PayloadControllerVtaDid {
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 PayloadControllerVtaDid {
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 PayloadControllerVtaDid {
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 PayloadControllerVtaDid {
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 device's platform push channel — the body the device registers with its push GATEWAY (push wake-up binding, https://trusttasks.org/binding/push/0.1; modeled on Aries RFC 0699/0734). The gateway holds this token and returns an opaque WakeHandle in exchange; the token is held by the gateway ONLY, never by the mediator or the maintainer/VTA. The gateway uses it to send a contentless wake-up when an authorized trigger asks — the push payload never carries Trust Task content. Tagged union over the discriminator `platform`.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "PushRegistration",
/// "description": "A device's platform push channel — the body the device registers with its push GATEWAY (push wake-up binding, https://trusttasks.org/binding/push/0.1; modeled on Aries RFC 0699/0734). The gateway holds this token and returns an opaque WakeHandle in exchange; the token is held by the gateway ONLY, never by the mediator or the maintainer/VTA. The gateway uses it to send a contentless wake-up when an authorized trigger asks — the push payload never carries Trust Task content. Tagged union over the discriminator `platform`.",
/// "oneOf": [
/// {
/// "title": "Apns",
/// "type": "object",
/// "required": [
/// "platform",
/// "token",
/// "topic"
/// ],
/// "properties": {
/// "environment": {
/// "description": "Which APNs environment issued the token. Maintainers route to the matching APNs endpoint.",
/// "type": "string",
/// "enum": [
/// "sandbox",
/// "production"
/// ]
/// },
/// "platform": {
/// "const": "apns"
/// },
/// "token": {
/// "description": "APNs device token (hex string issued by Apple Push Notification service).",
/// "type": "string",
/// "minLength": 1
/// },
/// "topic": {
/// "description": "APNs topic — typically the app bundle identifier the gateway pushes to.",
/// "type": "string",
/// "minLength": 1
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "Fcm",
/// "type": "object",
/// "required": [
/// "platform",
/// "token"
/// ],
/// "properties": {
/// "platform": {
/// "const": "fcm"
/// },
/// "token": {
/// "description": "Firebase Cloud Messaging registration token. The gateway sends a data message (not a notification message) so the app controls wake and display.",
/// "type": "string",
/// "minLength": 1
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "WebPush",
/// "type": "object",
/// "required": [
/// "endpoint",
/// "keys",
/// "platform"
/// ],
/// "properties": {
/// "endpoint": {
/// "description": "RFC 8030 Web Push subscription endpoint.",
/// "type": "string",
/// "format": "uri"
/// },
/// "keys": {
/// "description": "Web Push (RFC 8291) encryption keys. Note: per the push binding the payload remains contentless regardless of this encryption.",
/// "type": "object",
/// "required": [
/// "auth",
/// "p256dh"
/// ],
/// "properties": {
/// "auth": {
/// "description": "base64url-encoded auth secret.",
/// "type": "string",
/// "minLength": 1
/// },
/// "p256dh": {
/// "description": "base64url-encoded P-256 ECDH public key.",
/// "type": "string",
/// "minLength": 1
/// }
/// },
/// "additionalProperties": false
/// },
/// "platform": {
/// "const": "webpush"
/// }
/// },
/// "additionalProperties": false
/// }
/// ]
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(tag = "platform", deny_unknown_fields)]
pub enum PushRegistration {
///Apns
#[serde(rename = "apns")]
Apns {
///Which APNs environment issued the token. Maintainers route to the matching APNs endpoint.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
environment: ::std::option::Option<PushRegistrationEnvironment>,
///APNs device token (hex string issued by Apple Push Notification service).
token: PushRegistrationToken,
///APNs topic — typically the app bundle identifier the gateway pushes to.
topic: PushRegistrationTopic,
},
///Fcm
#[serde(rename = "fcm")]
Fcm {
///Firebase Cloud Messaging registration token. The gateway sends a data message (not a notification message) so the app controls wake and display.
token: PushRegistrationToken,
},
///WebPush
#[serde(rename = "webpush")]
Webpush {
///RFC 8030 Web Push subscription endpoint.
endpoint: ::std::string::String,
keys: PushRegistrationKeys,
},
}
///Which APNs environment issued the token. Maintainers route to the matching APNs endpoint.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Which APNs environment issued the token. Maintainers route to the matching APNs endpoint.",
/// "type": "string",
/// "enum": [
/// "sandbox",
/// "production"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
pub enum PushRegistrationEnvironment {
#[serde(rename = "sandbox")]
Sandbox,
#[serde(rename = "production")]
Production,
}
impl ::std::fmt::Display for PushRegistrationEnvironment {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Sandbox => f.write_str("sandbox"),
Self::Production => f.write_str("production"),
}
}
}
impl ::std::str::FromStr for PushRegistrationEnvironment {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"sandbox" => Ok(Self::Sandbox),
"production" => Ok(Self::Production),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for PushRegistrationEnvironment {
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 PushRegistrationEnvironment {
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 PushRegistrationEnvironment {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Web Push (RFC 8291) encryption keys. Note: per the push binding the payload remains contentless regardless of this encryption.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Web Push (RFC 8291) encryption keys. Note: per the push binding the payload remains contentless regardless of this encryption.",
/// "type": "object",
/// "required": [
/// "auth",
/// "p256dh"
/// ],
/// "properties": {
/// "auth": {
/// "description": "base64url-encoded auth secret.",
/// "type": "string",
/// "minLength": 1
/// },
/// "p256dh": {
/// "description": "base64url-encoded P-256 ECDH public key.",
/// "type": "string",
/// "minLength": 1
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct PushRegistrationKeys {
///base64url-encoded auth secret.
pub auth: PushRegistrationKeysAuth,
///base64url-encoded P-256 ECDH public key.
pub p256dh: PushRegistrationKeysP256dh,
}
///base64url-encoded auth secret.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "base64url-encoded auth secret.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PushRegistrationKeysAuth(::std::string::String);
impl ::std::ops::Deref for PushRegistrationKeysAuth {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PushRegistrationKeysAuth> for ::std::string::String {
fn from(value: PushRegistrationKeysAuth) -> Self {
value.0
}
}
impl ::std::str::FromStr for PushRegistrationKeysAuth {
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 PushRegistrationKeysAuth {
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 PushRegistrationKeysAuth {
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 PushRegistrationKeysAuth {
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 PushRegistrationKeysAuth {
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())
})
}
}
///base64url-encoded P-256 ECDH public key.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "base64url-encoded P-256 ECDH public key.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PushRegistrationKeysP256dh(::std::string::String);
impl ::std::ops::Deref for PushRegistrationKeysP256dh {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PushRegistrationKeysP256dh> for ::std::string::String {
fn from(value: PushRegistrationKeysP256dh) -> Self {
value.0
}
}
impl ::std::str::FromStr for PushRegistrationKeysP256dh {
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 PushRegistrationKeysP256dh {
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 PushRegistrationKeysP256dh {
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 PushRegistrationKeysP256dh {
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 PushRegistrationKeysP256dh {
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())
})
}
}
///APNs device token (hex string issued by Apple Push Notification service).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "APNs device token (hex string issued by Apple Push Notification service).",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PushRegistrationToken(::std::string::String);
impl ::std::ops::Deref for PushRegistrationToken {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PushRegistrationToken> for ::std::string::String {
fn from(value: PushRegistrationToken) -> Self {
value.0
}
}
impl ::std::str::FromStr for PushRegistrationToken {
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 PushRegistrationToken {
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 PushRegistrationToken {
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 PushRegistrationToken {
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 PushRegistrationToken {
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())
})
}
}
///APNs topic — typically the app bundle identifier the gateway pushes to.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "APNs topic — typically the app bundle identifier the gateway pushes to.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PushRegistrationTopic(::std::string::String);
impl ::std::ops::Deref for PushRegistrationTopic {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PushRegistrationTopic> for ::std::string::String {
fn from(value: PushRegistrationTopic) -> Self {
value.0
}
}
impl ::std::str::FromStr for PushRegistrationTopic {
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 PushRegistrationTopic {
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 PushRegistrationTopic {
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 PushRegistrationTopic {
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 PushRegistrationTopic {
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())
})
}
}
///`Response`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "type": "object",
/// "required": [
/// "wakeHandle"
/// ],
/// "properties": {
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "wakeHandle": {
/// "description": "The opaque gateway-issued handle (gateway address + handle). Conveyed onward; reveals no token.",
/// "$ref": "#/definitions/WakeHandle"
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "response"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Response {
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///The opaque gateway-issued handle (gateway address + handle). Conveyed onward; reveals no token.
#[serde(rename = "wakeHandle")]
pub wake_handle: WakeHandle,
}
///An opaque, gateway-issued reference to a device's push channel (push wake-up binding, https://trusttasks.org/binding/push/0.1). The push gateway returns it to the device at registration; the device conveys it to its VTA (device/set-wake), and the VTA provisions it to authorized triggers (its mediator and/or itself). The raw platform push token (APNs/FCM/WebPush) is held ONLY by the gateway and is never represented here — the handle abstracts the platform, so adding new push methods (e.g. PWA Web Push) needs no change to triggers or VTA config. A handle is a bearer capability to *request* a wake (subject to the gateway's allowlist), never to read the channel.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "WakeHandle",
/// "description": "An opaque, gateway-issued reference to a device's push channel (push wake-up binding, https://trusttasks.org/binding/push/0.1). The push gateway returns it to the device at registration; the device conveys it to its VTA (device/set-wake), and the VTA provisions it to authorized triggers (its mediator and/or itself). The raw platform push token (APNs/FCM/WebPush) is held ONLY by the gateway and is never represented here — the handle abstracts the platform, so adding new push methods (e.g. PWA Web Push) needs no change to triggers or VTA config. A handle is a bearer capability to *request* a wake (subject to the gateway's allowlist), never to read the channel.",
/// "type": "object",
/// "required": [
/// "gateway",
/// "handle"
/// ],
/// "properties": {
/// "gateway": {
/// "description": "The push gateway that issued this handle and acts on it — a DID (DIDComm-reachable gateway) or an https URL (REST gateway). A trigger sends its contentless wake request here.",
/// "type": "string",
/// "minLength": 1
/// },
/// "handle": {
/// "description": "Opaque gateway-issued identifier for the device's push channel. Reveals no platform token. Rotates whenever the device re-registers a new platform token with the gateway; the device then re-conveys the fresh handle via device/set-wake.",
/// "type": "string",
/// "minLength": 1
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct WakeHandle {
///The push gateway that issued this handle and acts on it — a DID (DIDComm-reachable gateway) or an https URL (REST gateway). A trigger sends its contentless wake request here.
pub gateway: WakeHandleGateway,
///Opaque gateway-issued identifier for the device's push channel. Reveals no platform token. Rotates whenever the device re-registers a new platform token with the gateway; the device then re-conveys the fresh handle via device/set-wake.
pub handle: WakeHandleHandle,
}
///The push gateway that issued this handle and acts on it — a DID (DIDComm-reachable gateway) or an https URL (REST gateway). A trigger sends its contentless wake request here.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The push gateway that issued this handle and acts on it — a DID (DIDComm-reachable gateway) or an https URL (REST gateway). A trigger sends its contentless wake request here.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct WakeHandleGateway(::std::string::String);
impl ::std::ops::Deref for WakeHandleGateway {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<WakeHandleGateway> for ::std::string::String {
fn from(value: WakeHandleGateway) -> Self {
value.0
}
}
impl ::std::str::FromStr for WakeHandleGateway {
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 WakeHandleGateway {
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 WakeHandleGateway {
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 WakeHandleGateway {
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 WakeHandleGateway {
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 gateway-issued identifier for the device's push channel. Reveals no platform token. Rotates whenever the device re-registers a new platform token with the gateway; the device then re-conveys the fresh handle via device/set-wake.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Opaque gateway-issued identifier for the device's push channel. Reveals no platform token. Rotates whenever the device re-registers a new platform token with the gateway; the device then re-conveys the fresh handle via device/set-wake.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct WakeHandleHandle(::std::string::String);
impl ::std::ops::Deref for WakeHandleHandle {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<WakeHandleHandle> for ::std::string::String {
fn from(value: WakeHandleHandle) -> Self {
value.0
}
}
impl ::std::str::FromStr for WakeHandleHandle {
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 WakeHandleHandle {
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 WakeHandleHandle {
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 WakeHandleHandle {
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 WakeHandleHandle {
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())
})
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/push/register/0.1";
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/push/register/0.1#response";
}
#[cfg(feature = "validate")]
impl crate::validate::ValidatedPayload for Payload {
const SCHEMA_JSON: &'static str = "{\n \"$defs\": {\n \"Ext\": {\n \"additionalProperties\": true,\n \"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.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"PushRegistration\": {\n \"description\": \"A device's platform push channel — the body the device registers with its push GATEWAY (push wake-up binding, https://trusttasks.org/binding/push/0.1; modeled on Aries RFC 0699/0734). The gateway holds this token and returns an opaque WakeHandle in exchange; the token is held by the gateway ONLY, never by the mediator or the maintainer/VTA. The gateway uses it to send a contentless wake-up when an authorized trigger asks — the push payload never carries Trust Task content. Tagged union over the discriminator `platform`.\",\n \"oneOf\": [\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"environment\": {\n \"description\": \"Which APNs environment issued the token. Maintainers route to the matching APNs endpoint.\",\n \"enum\": [\n \"sandbox\",\n \"production\"\n ],\n \"type\": \"string\"\n },\n \"platform\": {\n \"const\": \"apns\"\n },\n \"token\": {\n \"description\": \"APNs device token (hex string issued by Apple Push Notification service).\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"topic\": {\n \"description\": \"APNs topic — typically the app bundle identifier the gateway pushes to.\",\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"platform\",\n \"token\",\n \"topic\"\n ],\n \"title\": \"Apns\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"platform\": {\n \"const\": \"fcm\"\n },\n \"token\": {\n \"description\": \"Firebase Cloud Messaging registration token. The gateway sends a data message (not a notification message) so the app controls wake and display.\",\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"platform\",\n \"token\"\n ],\n \"title\": \"Fcm\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"endpoint\": {\n \"description\": \"RFC 8030 Web Push subscription endpoint.\",\n \"format\": \"uri\",\n \"type\": \"string\"\n },\n \"keys\": {\n \"additionalProperties\": false,\n \"description\": \"Web Push (RFC 8291) encryption keys. Note: per the push binding the payload remains contentless regardless of this encryption.\",\n \"properties\": {\n \"auth\": {\n \"description\": \"base64url-encoded auth secret.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"p256dh\": {\n \"description\": \"base64url-encoded P-256 ECDH public key.\",\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"p256dh\",\n \"auth\"\n ],\n \"type\": \"object\"\n },\n \"platform\": {\n \"const\": \"webpush\"\n }\n },\n \"required\": [\n \"platform\",\n \"endpoint\",\n \"keys\"\n ],\n \"title\": \"WebPush\",\n \"type\": \"object\"\n }\n ],\n \"title\": \"PushRegistration\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"wakeHandle\": {\n \"$ref\": \"#/$defs/WakeHandle\",\n \"description\": \"The opaque gateway-issued handle (gateway address + handle). Conveyed onward; reveals no token.\"\n }\n },\n \"required\": [\n \"wakeHandle\"\n ],\n \"title\": \"Push Register — response payload\",\n \"type\": \"object\"\n },\n \"WakeHandle\": {\n \"additionalProperties\": false,\n \"description\": \"An opaque, gateway-issued reference to a device's push channel (push wake-up binding, https://trusttasks.org/binding/push/0.1). The push gateway returns it to the device at registration; the device conveys it to its VTA (device/set-wake), and the VTA provisions it to authorized triggers (its mediator and/or itself). The raw platform push token (APNs/FCM/WebPush) is held ONLY by the gateway and is never represented here — the handle abstracts the platform, so adding new push methods (e.g. PWA Web Push) needs no change to triggers or VTA config. A handle is a bearer capability to *request* a wake (subject to the gateway's allowlist), never to read the channel.\",\n \"properties\": {\n \"gateway\": {\n \"description\": \"The push gateway that issued this handle and acts on it — a DID (DIDComm-reachable gateway) or an https URL (REST gateway). A trigger sends its contentless wake request here.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"handle\": {\n \"description\": \"Opaque gateway-issued identifier for the device's push channel. Reveals no platform token. Rotates whenever the device re-registers a new platform token with the gateway; the device then re-conveys the fresh handle via device/set-wake.\",\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"gateway\",\n \"handle\"\n ],\n \"title\": \"WakeHandle\",\n \"type\": \"object\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/push/register/0.1\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"A device registers its platform push token (APNs / FCM / Web Push) with a push gateway and names the controller VTA permitted to provision its trigger allowlist. The gateway returns an opaque WakeHandle; the raw token is held by the gateway only. See the push wake-up binding (https://trusttasks.org/binding/push/0.1).\",\n \"properties\": {\n \"controllerVtaDid\": {\n \"description\": \"The DID of the VTA permitted to provision this handle's trigger allowlist (push/provision). The device conveys the resulting handle to this VTA via device/set-wake.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"registration\": {\n \"$ref\": \"#/$defs/PushRegistration\",\n \"description\": \"The platform push channel (token). Held by the gateway only — never disclosed to any other party.\"\n }\n },\n \"required\": [\n \"registration\",\n \"controllerVtaDid\"\n ],\n \"title\": \"Push Register — payload\",\n \"type\": \"object\"\n}\n";
}