//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `vta/webvh/dids/create`. Version: `1.2`.
/// Why this specification version is deprecated (SPEC "Superseded and
/// Withdrawn Versions"), or `None` while it is current.
pub const DEPRECATION: Option<&str> = None;
#[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())
}
}
}
///The identity a did:webvh log is presented as. `webvh` is `did:webvh:<scid>:<host>[:<path>]`. `scid` is `did:scid:vh:1:<scid>`, verified by the same log and located by `?src=<host>[/<path>]`; it requires the alias in `alsoKnownAs`. In a request, absent means the VTA applies its configuration (`webvh` unless configured otherwise); in a response, the form the VTA applied, and `did` is in that form.
///
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum DidMethod {
#[serde(rename = "webvh")]
Webvh,
#[serde(rename = "scid")]
Scid,
}
impl ::std::fmt::Display for DidMethod {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Webvh => f.write_str("webvh"),
Self::Scid => f.write_str("scid"),
}
}
}
impl ::std::str::FromStr for DidMethod {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"webvh" => Ok(Self::Webvh),
"scid" => Ok(Self::Scid),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for DidMethod {
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 DidMethod {
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 DidMethod {
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())
})
}
}
///Mint a did:webvh: the VTA generates the keys, writes the log's first entry, and either hands it to a hosting server or returns it for the caller to serve.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///Add a DIDComm mediator service entry to the document.
#[serde(
rename = "addMediatorService",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub add_mediator_service: ::std::option::Option<bool>,
///Add a TSP transport service entry to the document.
#[serde(
rename = "addTspService",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub add_tsp_service: ::std::option::Option<bool>,
///Further service entries, verbatim.
#[serde(
rename = "additionalServices",
default,
skip_serializing_if = "::std::vec::Vec::is_empty"
)]
pub additional_services:
::std::vec::Vec<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
///Context the DID belongs to. Its keys are minted here, and deleting the context destroys the DID.
#[serde(rename = "contextId")]
pub context_id: PayloadContextId,
///A DID document to publish rather than one the VTA composes.
#[serde(
rename = "didDocument",
default,
skip_serializing_if = "::serde_json::Map::is_empty"
)]
pub did_document: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
///An existing log to adopt, for importing a DID minted elsewhere.
#[serde(
rename = "didLog",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub did_log: ::std::option::Option<::std::string::String>,
#[serde(
rename = "didMethod",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub did_method: ::std::option::Option<DidMethod>,
///Hosting domain to publish under, when the server serves more than one.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub domain: ::std::option::Option<::std::string::String>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///Existing key-agreement key to publish. Absent mints a new one.
#[serde(
rename = "kaKeyId",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub ka_key_id: ::std::option::Option<::std::string::String>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub label: ::std::option::Option<PayloadLabel>,
///Explicit path label under the host. Shorthand for pathMode `explicit`; supplying both is an error.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub path: ::std::option::Option<::std::string::String>,
///How the path under the host is chosen. Absent means `autoAssign`.
#[serde(
rename = "pathMode",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub path_mode: ::std::option::Option<WebvhPathMode>,
///Whether this DID may later move to another domain and keep its identity. **Fixed at creation** — portability is committed in the first log entry and cannot be added afterwards. A DID created non-portable is tied to where it was published for its whole life.
#[serde(default)]
pub portable: bool,
///How many successor keys to commit in advance. **`0` disables pre-rotation**, which means a compromise of the current key cannot be recovered from by rotating: the successor was never committed, so a thief can rotate to their own key as convincingly as the owner can.
#[serde(
rename = "preRotationCount",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub pre_rotation_count: ::std::option::Option<u64>,
///Whether the first log entry lists the `did:scid:vh:1` DID URL of the new log (with `src`) in `alsoKnownAs`, linking the two forms as one subject. Absent means the VTA applies its configuration, which defaults to `true`. `false` with `didMethod` `scid` is refused.
#[serde(
rename = "scidAlsoKnownAs",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub scid_also_known_as: ::std::option::Option<bool>,
///Hosting server to publish through. Absent means **serverless**: the caller serves the log itself at `url`, and the VTA holds no hosting registration for it.
#[serde(
rename = "serverId",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub server_id: ::std::option::Option<::std::string::String>,
///Make this the context's primary DID.
#[serde(
rename = "setPrimary",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub set_primary: ::std::option::Option<bool>,
///Existing key to sign log entries with. Absent mints a new one.
#[serde(
rename = "signingKeyId",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub signing_key_id: ::std::option::Option<::std::string::String>,
///DID template to render the document from (see vta/did-templates/*).
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub template: ::std::option::Option<::std::string::String>,
///Context whose templates to resolve `template` against. Absent uses the global scope, which is a different namespace and may hold a different template of the same name.
#[serde(
rename = "templateContext",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub template_context: ::std::option::Option<::std::string::String>,
///Variables for the template's placeholders.
#[serde(
rename = "templateVars",
default,
skip_serializing_if = ":: std :: collections :: HashMap::is_empty"
)]
pub template_vars: ::std::collections::HashMap<::std::string::String, ::std::string::String>,
///Where the log will be served, for the serverless case. The DID's identity derives from this location, so changing it later is only possible for a `portable` DID.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub url: ::std::option::Option<::std::string::String>,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///Context the DID belongs to. Its keys are minted here, and deleting the context destroys the DID.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadContextId(::std::string::String);
impl ::std::ops::Deref for PayloadContextId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadContextId> for ::std::string::String {
fn from(value: PayloadContextId) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadContextId {
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 PayloadContextId {
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 PayloadContextId {
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 PayloadContextId {
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 PayloadContextId {
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())
})
}
}
///`PayloadLabel`
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadLabel(::std::string::String);
impl ::std::ops::Deref for PayloadLabel {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadLabel> for ::std::string::String {
fn from(value: PayloadLabel) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadLabel {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 256usize {
return Err("longer than 256 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadLabel {
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 PayloadLabel {
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 PayloadLabel {
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 PayloadLabel {
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())
})
}
}
///Success response to vta/webvh/dids/create. Type https://trusttasks.org/spec/vta/webvh/dids/create/1.2#response.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
#[serde(rename = "contextId")]
pub context_id: ::std::string::String,
#[serde(rename = "createdAt")]
pub created_at: ::chrono::DateTime<::chrono::offset::Utc>,
///The new identity, in the form `didMethod` names: the did:webvh DID, or the bare `did:scid:vh:1:<scid>` DID.
pub did: ::std::string::String,
///The published document, when the VTA composed one.
#[serde(
rename = "didDocument",
default,
skip_serializing_if = "::serde_json::Map::is_empty"
)]
pub did_document: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
#[serde(rename = "didMethod")]
pub did_method: DidMethod,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
#[serde(rename = "kaKeyId")]
pub ka_key_id: ::std::string::String,
///The log's first entry. For a serverless DID this is what the caller must serve — the DID does not resolve until they do.
#[serde(
rename = "logEntry",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub log_entry: ::std::option::Option<::std::string::String>,
///The hosting server's handle for the record. Absent for a serverless DID.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub mnemonic: ::std::option::Option<::std::string::String>,
pub portable: bool,
///Successor keys committed. `0` means pre-rotation is off for this DID.
#[serde(rename = "preRotationKeyCount")]
pub pre_rotation_key_count: u64,
///Self-certifying identifier committing to the log's first entry.
pub scid: ::std::string::String,
///Whether the first log entry lists `scidDidUrl` in `alsoKnownAs`.
#[serde(rename = "scidAlsoKnownAs")]
pub scid_also_known_as: bool,
///The `did:scid:vh:1:<scid>?src=<source>` DID URL of the log: the did:scid DID with the locator a recipient needs to resolve it. A producer gives this out, rather than the bare DID, wherever the recipient may not hold a source.
#[serde(rename = "scidDidUrl")]
pub scid_did_url: ::std::string::String,
///The hosting server the DID was published through. Absent exactly when `serverless` is true.
#[serde(
rename = "serverId",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub server_id: ::std::option::Option<::std::string::String>,
///True when no hosting server was published to: the VTA holds the log, and the DID does not resolve until the caller serves `logEntry` at the DID's URL. Stated, rather than left to be inferred from an absent `serverId`, so a client can refuse to rely on a DID nobody serves.
pub serverless: bool,
#[serde(rename = "signingKeyId")]
pub signing_key_id: ::std::string::String,
///The did:webvh DID of the log. Equal to `did` when `didMethod` is `webvh`.
#[serde(rename = "webvhDid")]
pub webvh_did: ::std::string::String,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///Where under the host the DID is served. `wellKnown` puts it at the host root (`/.well-known/did.jsonl`) — at most one DID per host can hold that. `explicit` names the path. `autoAssign` lets the server allocate one.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(tag = "mode", content = "path")]
#[non_exhaustive]
pub enum WebvhPathMode {
#[serde(rename = "wellKnown")]
WellKnown,
#[serde(rename = "explicit")]
Explicit(WebvhPathModePath),
#[serde(rename = "autoAssign")]
AutoAssign,
}
impl ::std::convert::From<WebvhPathModePath> for WebvhPathMode {
fn from(value: WebvhPathModePath) -> Self {
Self::Explicit(value)
}
}
///`WebvhPathModePath`
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct WebvhPathModePath(::std::string::String);
impl ::std::ops::Deref for WebvhPathModePath {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<WebvhPathModePath> for ::std::string::String {
fn from(value: WebvhPathModePath) -> Self {
value.0
}
}
impl ::std::str::FromStr for WebvhPathModePath {
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 WebvhPathModePath {
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 WebvhPathModePath {
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 WebvhPathModePath {
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 WebvhPathModePath {
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 {
add_mediator_service:
::std::result::Result<::std::option::Option<bool>, ::std::string::String>,
add_tsp_service: ::std::result::Result<::std::option::Option<bool>, ::std::string::String>,
additional_services: ::std::result::Result<
::std::vec::Vec<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
::std::string::String,
>,
context_id: ::std::result::Result<super::PayloadContextId, ::std::string::String>,
did_document: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
did_log: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
did_method:
::std::result::Result<::std::option::Option<super::DidMethod>, ::std::string::String>,
domain: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
ka_key_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
label: ::std::result::Result<
::std::option::Option<super::PayloadLabel>,
::std::string::String,
>,
path: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
path_mode: ::std::result::Result<
::std::option::Option<super::WebvhPathMode>,
::std::string::String,
>,
portable: ::std::result::Result<bool, ::std::string::String>,
pre_rotation_count:
::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
scid_also_known_as:
::std::result::Result<::std::option::Option<bool>, ::std::string::String>,
server_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
set_primary: ::std::result::Result<::std::option::Option<bool>, ::std::string::String>,
signing_key_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
template: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
template_context: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
template_vars: ::std::result::Result<
::std::collections::HashMap<::std::string::String, ::std::string::String>,
::std::string::String,
>,
url: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
add_mediator_service: Ok(Default::default()),
add_tsp_service: Ok(Default::default()),
additional_services: Ok(Default::default()),
context_id: Err("no value supplied for context_id".to_string()),
did_document: Ok(Default::default()),
did_log: Ok(Default::default()),
did_method: Ok(Default::default()),
domain: Ok(Default::default()),
ext: Ok(Default::default()),
ka_key_id: Ok(Default::default()),
label: Ok(Default::default()),
path: Ok(Default::default()),
path_mode: Ok(Default::default()),
portable: Ok(Default::default()),
pre_rotation_count: Ok(Default::default()),
scid_also_known_as: Ok(Default::default()),
server_id: Ok(Default::default()),
set_primary: Ok(Default::default()),
signing_key_id: Ok(Default::default()),
template: Ok(Default::default()),
template_context: Ok(Default::default()),
template_vars: Ok(Default::default()),
url: Ok(Default::default()),
}
}
}
impl Payload {
pub fn add_mediator_service<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.add_mediator_service = value.try_into().map_err(|e| {
format!("error converting supplied value for add_mediator_service: {e}")
});
self
}
pub fn add_tsp_service<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.add_tsp_service = value
.try_into()
.map_err(|e| format!("error converting supplied value for add_tsp_service: {e}"));
self
}
pub fn additional_services<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::vec::Vec<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
>,
T::Error: ::std::fmt::Display,
{
self.additional_services = value.try_into().map_err(|e| {
format!("error converting supplied value for additional_services: {e}")
});
self
}
pub fn context_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadContextId>,
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 did_document<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.did_document = value
.try_into()
.map_err(|e| format!("error converting supplied value for did_document: {e}"));
self
}
pub fn did_log<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.did_log = value
.try_into()
.map_err(|e| format!("error converting supplied value for did_log: {e}"));
self
}
pub fn did_method<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::DidMethod>>,
T::Error: ::std::fmt::Display,
{
self.did_method = value
.try_into()
.map_err(|e| format!("error converting supplied value for did_method: {e}"));
self
}
pub fn domain<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.domain = value
.try_into()
.map_err(|e| format!("error converting supplied value for domain: {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 ka_key_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.ka_key_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for ka_key_id: {e}"));
self
}
pub fn label<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadLabel>>,
T::Error: ::std::fmt::Display,
{
self.label = value
.try_into()
.map_err(|e| format!("error converting supplied value for label: {e}"));
self
}
pub fn path<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.path = value
.try_into()
.map_err(|e| format!("error converting supplied value for path: {e}"));
self
}
pub fn path_mode<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::WebvhPathMode>>,
T::Error: ::std::fmt::Display,
{
self.path_mode = value
.try_into()
.map_err(|e| format!("error converting supplied value for path_mode: {e}"));
self
}
pub fn portable<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.portable = value
.try_into()
.map_err(|e| format!("error converting supplied value for portable: {e}"));
self
}
pub fn pre_rotation_count<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.pre_rotation_count = value.try_into().map_err(|e| {
format!("error converting supplied value for pre_rotation_count: {e}")
});
self
}
pub fn scid_also_known_as<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.scid_also_known_as = value.try_into().map_err(|e| {
format!("error converting supplied value for scid_also_known_as: {e}")
});
self
}
pub fn server_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.server_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for server_id: {e}"));
self
}
pub fn set_primary<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.set_primary = value
.try_into()
.map_err(|e| format!("error converting supplied value for set_primary: {e}"));
self
}
pub fn signing_key_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.signing_key_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for signing_key_id: {e}"));
self
}
pub fn template<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.template = value
.try_into()
.map_err(|e| format!("error converting supplied value for template: {e}"));
self
}
pub fn template_context<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.template_context = value
.try_into()
.map_err(|e| format!("error converting supplied value for template_context: {e}"));
self
}
pub fn template_vars<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::collections::HashMap<::std::string::String, ::std::string::String>,
>,
T::Error: ::std::fmt::Display,
{
self.template_vars = value
.try_into()
.map_err(|e| format!("error converting supplied value for template_vars: {e}"));
self
}
pub fn url<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.url = value
.try_into()
.map_err(|e| format!("error converting supplied value for url: {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 {
add_mediator_service: value.add_mediator_service?,
add_tsp_service: value.add_tsp_service?,
additional_services: value.additional_services?,
context_id: value.context_id?,
did_document: value.did_document?,
did_log: value.did_log?,
did_method: value.did_method?,
domain: value.domain?,
ext: value.ext?,
ka_key_id: value.ka_key_id?,
label: value.label?,
path: value.path?,
path_mode: value.path_mode?,
portable: value.portable?,
pre_rotation_count: value.pre_rotation_count?,
scid_also_known_as: value.scid_also_known_as?,
server_id: value.server_id?,
set_primary: value.set_primary?,
signing_key_id: value.signing_key_id?,
template: value.template?,
template_context: value.template_context?,
template_vars: value.template_vars?,
url: value.url?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
add_mediator_service: Ok(value.add_mediator_service),
add_tsp_service: Ok(value.add_tsp_service),
additional_services: Ok(value.additional_services),
context_id: Ok(value.context_id),
did_document: Ok(value.did_document),
did_log: Ok(value.did_log),
did_method: Ok(value.did_method),
domain: Ok(value.domain),
ext: Ok(value.ext),
ka_key_id: Ok(value.ka_key_id),
label: Ok(value.label),
path: Ok(value.path),
path_mode: Ok(value.path_mode),
portable: Ok(value.portable),
pre_rotation_count: Ok(value.pre_rotation_count),
scid_also_known_as: Ok(value.scid_also_known_as),
server_id: Ok(value.server_id),
set_primary: Ok(value.set_primary),
signing_key_id: Ok(value.signing_key_id),
template: Ok(value.template),
template_context: Ok(value.template_context),
template_vars: Ok(value.template_vars),
url: Ok(value.url),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
context_id: ::std::result::Result<::std::string::String, ::std::string::String>,
created_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
did: ::std::result::Result<::std::string::String, ::std::string::String>,
did_document: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
did_method: ::std::result::Result<super::DidMethod, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
ka_key_id: ::std::result::Result<::std::string::String, ::std::string::String>,
log_entry: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
mnemonic: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
portable: ::std::result::Result<bool, ::std::string::String>,
pre_rotation_key_count: ::std::result::Result<u64, ::std::string::String>,
scid: ::std::result::Result<::std::string::String, ::std::string::String>,
scid_also_known_as: ::std::result::Result<bool, ::std::string::String>,
scid_did_url: ::std::result::Result<::std::string::String, ::std::string::String>,
server_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
serverless: ::std::result::Result<bool, ::std::string::String>,
signing_key_id: ::std::result::Result<::std::string::String, ::std::string::String>,
webvh_did: ::std::result::Result<::std::string::String, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
context_id: Err("no value supplied for context_id".to_string()),
created_at: Err("no value supplied for created_at".to_string()),
did: Err("no value supplied for did".to_string()),
did_document: Ok(Default::default()),
did_method: Err("no value supplied for did_method".to_string()),
ext: Ok(Default::default()),
ka_key_id: Err("no value supplied for ka_key_id".to_string()),
log_entry: Ok(Default::default()),
mnemonic: Ok(Default::default()),
portable: Err("no value supplied for portable".to_string()),
pre_rotation_key_count: Err(
"no value supplied for pre_rotation_key_count".to_string()
),
scid: Err("no value supplied for scid".to_string()),
scid_also_known_as: Err("no value supplied for scid_also_known_as".to_string()),
scid_did_url: Err("no value supplied for scid_did_url".to_string()),
server_id: Ok(Default::default()),
serverless: Err("no value supplied for serverless".to_string()),
signing_key_id: Err("no value supplied for signing_key_id".to_string()),
webvh_did: Err("no value supplied for webvh_did".to_string()),
}
}
}
impl Response {
pub fn context_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
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 created_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.created_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for created_at: {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 did_document<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.did_document = value
.try_into()
.map_err(|e| format!("error converting supplied value for did_document: {e}"));
self
}
pub fn did_method<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::DidMethod>,
T::Error: ::std::fmt::Display,
{
self.did_method = value
.try_into()
.map_err(|e| format!("error converting supplied value for did_method: {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 ka_key_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.ka_key_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for ka_key_id: {e}"));
self
}
pub fn log_entry<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.log_entry = value
.try_into()
.map_err(|e| format!("error converting supplied value for log_entry: {e}"));
self
}
pub fn mnemonic<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.mnemonic = value
.try_into()
.map_err(|e| format!("error converting supplied value for mnemonic: {e}"));
self
}
pub fn portable<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.portable = value
.try_into()
.map_err(|e| format!("error converting supplied value for portable: {e}"));
self
}
pub fn pre_rotation_key_count<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.pre_rotation_key_count = value.try_into().map_err(|e| {
format!("error converting supplied value for pre_rotation_key_count: {e}")
});
self
}
pub fn scid<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.scid = value
.try_into()
.map_err(|e| format!("error converting supplied value for scid: {e}"));
self
}
pub fn scid_also_known_as<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.scid_also_known_as = value.try_into().map_err(|e| {
format!("error converting supplied value for scid_also_known_as: {e}")
});
self
}
pub fn scid_did_url<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.scid_did_url = value
.try_into()
.map_err(|e| format!("error converting supplied value for scid_did_url: {e}"));
self
}
pub fn server_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.server_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for server_id: {e}"));
self
}
pub fn serverless<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.serverless = value
.try_into()
.map_err(|e| format!("error converting supplied value for serverless: {e}"));
self
}
pub fn signing_key_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.signing_key_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for signing_key_id: {e}"));
self
}
pub fn webvh_did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.webvh_did = value
.try_into()
.map_err(|e| format!("error converting supplied value for webvh_did: {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 {
context_id: value.context_id?,
created_at: value.created_at?,
did: value.did?,
did_document: value.did_document?,
did_method: value.did_method?,
ext: value.ext?,
ka_key_id: value.ka_key_id?,
log_entry: value.log_entry?,
mnemonic: value.mnemonic?,
portable: value.portable?,
pre_rotation_key_count: value.pre_rotation_key_count?,
scid: value.scid?,
scid_also_known_as: value.scid_also_known_as?,
scid_did_url: value.scid_did_url?,
server_id: value.server_id?,
serverless: value.serverless?,
signing_key_id: value.signing_key_id?,
webvh_did: value.webvh_did?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
context_id: Ok(value.context_id),
created_at: Ok(value.created_at),
did: Ok(value.did),
did_document: Ok(value.did_document),
did_method: Ok(value.did_method),
ext: Ok(value.ext),
ka_key_id: Ok(value.ka_key_id),
log_entry: Ok(value.log_entry),
mnemonic: Ok(value.mnemonic),
portable: Ok(value.portable),
pre_rotation_key_count: Ok(value.pre_rotation_key_count),
scid: Ok(value.scid),
scid_also_known_as: Ok(value.scid_also_known_as),
scid_did_url: Ok(value.scid_did_url),
server_id: Ok(value.server_id),
serverless: Ok(value.serverless),
signing_key_id: Ok(value.signing_key_id),
webvh_did: Ok(value.webvh_did),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vta/webvh/dids/create/1.2";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"DidMethod\":{\"description\":\"The identity a did:webvh log is presented as. `webvh` is `did:webvh:<scid>:<host>[:<path>]`. `scid` is `did:scid:vh:1:<scid>`, verified by the same log and located by `?src=<host>[/<path>]`; it requires the alias in `alsoKnownAs`. In a request, absent means the VTA applies its configuration (`webvh` unless configured otherwise); in a response, the form the VTA applied, and `did` is in that form.\",\"enum\":[\"webvh\",\"scid\"],\"title\":\"DidMethod\",\"type\":\"string\"},\"Ext\":{\"additionalProperties\":true,\"description\":\"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\"minProperties\":1,\"propertyNames\":{\"pattern\":\"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"},\"title\":\"Ext\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"description\":\"Success response to vta/webvh/dids/create. Type https://trusttasks.org/spec/vta/webvh/dids/create/1.2#response.\",\"properties\":{\"contextId\":{\"type\":\"string\"},\"createdAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"did\":{\"description\":\"The new identity, in the form `didMethod` names: the did:webvh DID, or the bare `did:scid:vh:1:<scid>` DID.\",\"type\":\"string\"},\"didDocument\":{\"description\":\"The published document, when the VTA composed one.\",\"type\":\"object\"},\"didMethod\":{\"$ref\":\"#/$defs/DidMethod\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"kaKeyId\":{\"type\":\"string\"},\"logEntry\":{\"description\":\"The log's first entry. For a serverless DID this is what the caller must serve — the DID does not resolve until they do.\",\"type\":\"string\"},\"mnemonic\":{\"description\":\"The hosting server's handle for the record. Absent for a serverless DID.\",\"type\":\"string\"},\"portable\":{\"type\":\"boolean\"},\"preRotationKeyCount\":{\"description\":\"Successor keys committed. `0` means pre-rotation is off for this DID.\",\"minimum\":0,\"type\":\"integer\"},\"scid\":{\"description\":\"Self-certifying identifier committing to the log's first entry.\",\"type\":\"string\"},\"scidAlsoKnownAs\":{\"description\":\"Whether the first log entry lists `scidDidUrl` in `alsoKnownAs`.\",\"type\":\"boolean\"},\"scidDidUrl\":{\"description\":\"The `did:scid:vh:1:<scid>?src=<source>` DID URL of the log: the did:scid DID with the locator a recipient needs to resolve it. A producer gives this out, rather than the bare DID, wherever the recipient may not hold a source.\",\"type\":\"string\"},\"serverId\":{\"description\":\"The hosting server the DID was published through. Absent exactly when `serverless` is true.\",\"type\":\"string\"},\"serverless\":{\"description\":\"True when no hosting server was published to: the VTA holds the log, and the DID does not resolve until the caller serves `logEntry` at the DID's URL. Stated, rather than left to be inferred from an absent `serverId`, so a client can refuse to rely on a DID nobody serves.\",\"type\":\"boolean\"},\"signingKeyId\":{\"type\":\"string\"},\"webvhDid\":{\"description\":\"The did:webvh DID of the log. Equal to `did` when `didMethod` is `webvh`.\",\"type\":\"string\"}},\"required\":[\"did\",\"contextId\",\"serverless\",\"scid\",\"portable\",\"signingKeyId\",\"kaKeyId\",\"preRotationKeyCount\",\"createdAt\",\"didMethod\",\"scidAlsoKnownAs\",\"webvhDid\",\"scidDidUrl\"],\"title\":\"VTA WebVH DIDs Create — response payload\",\"type\":\"object\"},\"WebvhPathMode\":{\"description\":\"Where under the host the DID is served. `wellKnown` puts it at the host root (`/.well-known/did.jsonl`) — at most one DID per host can hold that. `explicit` names the path. `autoAssign` lets the server allocate one.\",\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"mode\":{\"const\":\"wellKnown\"}},\"required\":[\"mode\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"mode\":{\"const\":\"explicit\"},\"path\":{\"minLength\":1,\"type\":\"string\"}},\"required\":[\"mode\",\"path\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"mode\":{\"const\":\"autoAssign\"}},\"required\":[\"mode\"],\"type\":\"object\"}],\"title\":\"WebvhPathMode\"}},\"$id\":\"https://trusttasks.org/spec/vta/webvh/dids/create/1.2\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"additionalProperties\":false,\"description\":\"Mint a did:webvh: the VTA generates the keys, writes the log's first entry, and either hands it to a hosting server or returns it for the caller to serve.\",\"properties\":{\"addMediatorService\":{\"description\":\"Add a DIDComm mediator service entry to the document.\",\"type\":\"boolean\"},\"addTspService\":{\"description\":\"Add a TSP transport service entry to the document.\",\"type\":\"boolean\"},\"additionalServices\":{\"description\":\"Further service entries, verbatim.\",\"items\":{\"type\":\"object\"},\"type\":\"array\"},\"contextId\":{\"description\":\"Context the DID belongs to. Its keys are minted here, and deleting the context destroys the DID.\",\"minLength\":1,\"type\":\"string\"},\"didDocument\":{\"description\":\"A DID document to publish rather than one the VTA composes.\",\"type\":\"object\"},\"didLog\":{\"description\":\"An existing log to adopt, for importing a DID minted elsewhere.\",\"type\":\"string\"},\"didMethod\":{\"$ref\":\"#/$defs/DidMethod\"},\"domain\":{\"description\":\"Hosting domain to publish under, when the server serves more than one.\",\"type\":\"string\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"kaKeyId\":{\"description\":\"Existing key-agreement key to publish. Absent mints a new one.\",\"type\":\"string\"},\"label\":{\"maxLength\":256,\"type\":\"string\"},\"path\":{\"description\":\"Explicit path label under the host. Shorthand for pathMode `explicit`; supplying both is an error.\",\"type\":\"string\"},\"pathMode\":{\"$ref\":\"#/$defs/WebvhPathMode\",\"description\":\"How the path under the host is chosen. Absent means `autoAssign`.\"},\"portable\":{\"default\":false,\"description\":\"Whether this DID may later move to another domain and keep its identity. **Fixed at creation** — portability is committed in the first log entry and cannot be added afterwards. A DID created non-portable is tied to where it was published for its whole life.\",\"type\":\"boolean\"},\"preRotationCount\":{\"description\":\"How many successor keys to commit in advance. **`0` disables pre-rotation**, which means a compromise of the current key cannot be recovered from by rotating: the successor was never committed, so a thief can rotate to their own key as convincingly as the owner can.\",\"minimum\":0,\"type\":\"integer\"},\"scidAlsoKnownAs\":{\"description\":\"Whether the first log entry lists the `did:scid:vh:1` DID URL of the new log (with `src`) in `alsoKnownAs`, linking the two forms as one subject. Absent means the VTA applies its configuration, which defaults to `true`. `false` with `didMethod` `scid` is refused.\",\"type\":\"boolean\"},\"serverId\":{\"description\":\"Hosting server to publish through. Absent means **serverless**: the caller serves the log itself at `url`, and the VTA holds no hosting registration for it.\",\"type\":\"string\"},\"setPrimary\":{\"description\":\"Make this the context's primary DID.\",\"type\":\"boolean\"},\"signingKeyId\":{\"description\":\"Existing key to sign log entries with. Absent mints a new one.\",\"type\":\"string\"},\"template\":{\"description\":\"DID template to render the document from (see vta/did-templates/*).\",\"type\":\"string\"},\"templateContext\":{\"description\":\"Context whose templates to resolve `template` against. Absent uses the global scope, which is a different namespace and may hold a different template of the same name.\",\"type\":\"string\"},\"templateVars\":{\"additionalProperties\":{\"type\":\"string\"},\"description\":\"Variables for the template's placeholders.\",\"type\":\"object\"},\"url\":{\"description\":\"Where the log will be served, for the serverless case. The DID's identity derives from this location, so changing it later is only possible for a `portable` DID.\",\"type\":\"string\"}},\"required\":[\"contextId\"],\"title\":\"VTA WebVH DIDs Create — payload\",\"type\":\"object\"}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vta/webvh/dids/create/1.2#response";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"DidMethod\":{\"description\":\"The identity a did:webvh log is presented as. `webvh` is `did:webvh:<scid>:<host>[:<path>]`. `scid` is `did:scid:vh:1:<scid>`, verified by the same log and located by `?src=<host>[/<path>]`; it requires the alias in `alsoKnownAs`. In a request, absent means the VTA applies its configuration (`webvh` unless configured otherwise); in a response, the form the VTA applied, and `did` is in that form.\",\"enum\":[\"webvh\",\"scid\"],\"title\":\"DidMethod\",\"type\":\"string\"},\"Ext\":{\"additionalProperties\":true,\"description\":\"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\"minProperties\":1,\"propertyNames\":{\"pattern\":\"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"},\"title\":\"Ext\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"description\":\"Success response to vta/webvh/dids/create. Type https://trusttasks.org/spec/vta/webvh/dids/create/1.2#response.\",\"properties\":{\"contextId\":{\"type\":\"string\"},\"createdAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"did\":{\"description\":\"The new identity, in the form `didMethod` names: the did:webvh DID, or the bare `did:scid:vh:1:<scid>` DID.\",\"type\":\"string\"},\"didDocument\":{\"description\":\"The published document, when the VTA composed one.\",\"type\":\"object\"},\"didMethod\":{\"$ref\":\"#/$defs/DidMethod\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"kaKeyId\":{\"type\":\"string\"},\"logEntry\":{\"description\":\"The log's first entry. For a serverless DID this is what the caller must serve — the DID does not resolve until they do.\",\"type\":\"string\"},\"mnemonic\":{\"description\":\"The hosting server's handle for the record. Absent for a serverless DID.\",\"type\":\"string\"},\"portable\":{\"type\":\"boolean\"},\"preRotationKeyCount\":{\"description\":\"Successor keys committed. `0` means pre-rotation is off for this DID.\",\"minimum\":0,\"type\":\"integer\"},\"scid\":{\"description\":\"Self-certifying identifier committing to the log's first entry.\",\"type\":\"string\"},\"scidAlsoKnownAs\":{\"description\":\"Whether the first log entry lists `scidDidUrl` in `alsoKnownAs`.\",\"type\":\"boolean\"},\"scidDidUrl\":{\"description\":\"The `did:scid:vh:1:<scid>?src=<source>` DID URL of the log: the did:scid DID with the locator a recipient needs to resolve it. A producer gives this out, rather than the bare DID, wherever the recipient may not hold a source.\",\"type\":\"string\"},\"serverId\":{\"description\":\"The hosting server the DID was published through. Absent exactly when `serverless` is true.\",\"type\":\"string\"},\"serverless\":{\"description\":\"True when no hosting server was published to: the VTA holds the log, and the DID does not resolve until the caller serves `logEntry` at the DID's URL. Stated, rather than left to be inferred from an absent `serverId`, so a client can refuse to rely on a DID nobody serves.\",\"type\":\"boolean\"},\"signingKeyId\":{\"type\":\"string\"},\"webvhDid\":{\"description\":\"The did:webvh DID of the log. Equal to `did` when `didMethod` is `webvh`.\",\"type\":\"string\"}},\"required\":[\"did\",\"contextId\",\"serverless\",\"scid\",\"portable\",\"signingKeyId\",\"kaKeyId\",\"preRotationKeyCount\",\"createdAt\",\"didMethod\",\"scidAlsoKnownAs\",\"webvhDid\",\"scidDidUrl\"],\"title\":\"VTA WebVH DIDs Create — response payload\",\"type\":\"object\"},\"WebvhPathMode\":{\"description\":\"Where under the host the DID is served. `wellKnown` puts it at the host root (`/.well-known/did.jsonl`) — at most one DID per host can hold that. `explicit` names the path. `autoAssign` lets the server allocate one.\",\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"mode\":{\"const\":\"wellKnown\"}},\"required\":[\"mode\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"mode\":{\"const\":\"explicit\"},\"path\":{\"minLength\":1,\"type\":\"string\"}},\"required\":[\"mode\",\"path\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"mode\":{\"const\":\"autoAssign\"}},\"required\":[\"mode\"],\"type\":\"object\"}],\"title\":\"WebvhPathMode\"}},\"$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::PATH_TAKEN,
error_codes::TEMPLATE_NOT_FOUND,
error_codes::SCID_ALIAS_REQUIRED,
];
/// 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 {
/// `vta/webvh/dids/create:pathTaken`
///
/// The requested path is already in use on the hosting server.
///
/// Declared `retryable: false`.
pub const PATH_TAKEN: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/webvh/dids/create:pathTaken",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vta/webvh/dids/create:templateNotFound`
///
/// The named DID template does not exist in the selected scope.
///
/// Declared `retryable: false`.
pub const TEMPLATE_NOT_FOUND: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/webvh/dids/create:templateNotFound",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vta/webvh/dids/create:scidAliasRequired`
///
/// The did:scid form was requested, but the alias cannot be listed in alsoKnownAs: the request sets scidAlsoKnownAs to false, or the template, the supplied didDocument or the supplied didLog does not allow it.
///
/// Declared `retryable: false`.
pub const SCID_ALIAS_REQUIRED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/webvh/dids/create:scidAliasRequired",
retryable: false,
details_schema: ::core::option::Option::None,
};
}