credential_exchange_format/
document.rs

1//! # Document Credentials
2
3use serde::{Deserialize, Serialize};
4
5use crate::{B64Url, EditableField, EditableFieldString, Extension};
6
7#[derive(Clone, Debug, Serialize, Deserialize)]
8#[serde(rename_all = "camelCase", bound(deserialize = "E: Deserialize<'de>"))]
9pub struct CustomFieldsCredential<E = ()> {
10    /// A unique identifier for the CustomFields. It MUST be a machine-generated opaque byte
11    /// sequence with a maximum size of 64 bytes. It SHOULD NOT be displayed to the user.
12    #[serde(default, skip_serializing_if = "Option::is_none")]
13    pub id: Option<B64Url>,
14    /// This member is a [human-palatable](https://www.w3.org/TR/webauthn-3/#human-palatability)
15    /// title to describe the section. This value MAY be set by the credential owner.
16    #[serde(default, skip_serializing_if = "Option::is_none")]
17    pub label: Option<String>,
18    /// The collection of miscellaneous fields under this section.
19    pub fields: Vec<EditableField<EditableFieldString, E>>,
20    /// This member permits the exporting provider to add additional information associated to this
21    /// CustomFields. This MAY be used to provide an exchange where a minimal amount of information
22    /// is lost.
23    #[serde(default, skip_serializing_if = "Vec::is_empty")]
24    pub extensions: Vec<Extension<E>>,
25}
26
27/// A [FileCredential] acts as a placeholder to an arbitrary binary file holding its associated
28/// metadata. When an importing provider encounters a file credential, they MAY request the file
29/// afterwards if they have a direct exchange. If the exchange will produce an export response file,
30/// then the associated encrypted file MUST be stored in the documents folder of the zip archive.
31#[derive(Clone, Debug, Serialize, Deserialize)]
32#[serde(rename_all = "camelCase")]
33pub struct FileCredential {
34    /// The file’s identifier, used as the file name in the zip archive.
35    pub id: B64Url,
36    /// The file name with the file extension if applicable.
37    pub name: String,
38    /// The file’s decrypted size in bytes.
39    pub decrypted_size: u64,
40    /// The SHA256 hash of the decrypted file. This hash MUST be used by the importing provider
41    /// when the file is decrypted to ensure that it has not been corrupted.
42    pub integration_hash: B64Url,
43}
44
45#[derive(Clone, Debug, Serialize, Deserialize)]
46#[serde(rename_all = "camelCase", bound(deserialize = "E: Deserialize<'de>"))]
47pub struct NoteCredential<E = ()> {
48    /// This member is a user-defined value encoded as a UTF-8 string.
49    pub content: EditableField<EditableFieldString, E>,
50}