Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clone to Format #21

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions credential-exchange-types/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{

mod passkey;

#[derive(Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", bound(deserialize = "E: Deserialize<'de>"))]
pub struct Header<E = ()> {
/// The version of the format definition, The current version is 0.
Expand All @@ -21,7 +21,7 @@ pub struct Header<E = ()> {
pub accounts: Vec<Account<E>>,
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", bound(deserialize = "E: Deserialize<'de>"))]
pub struct Account<E = ()> {
/// A unique identifier for the [Account] which is machine generated and an opaque byte
Expand Down Expand Up @@ -49,7 +49,7 @@ pub struct Account<E = ()> {
pub extensions: Option<Vec<Extension<E>>>, // default []
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", bound(deserialize = "E: Deserialize<'de>"))]
pub struct Collection<E = ()> {
/// A unique identifier for the [Collection] which is machine generated and an opaque byte
Expand All @@ -75,7 +75,7 @@ pub struct Collection<E = ()> {
pub extensions: Option<Vec<Extension<E>>>, // default []
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", bound(deserialize = "E: Deserialize<'de>"))]
pub struct Item<E = ()> {
/// A unique identifier for the [Item] which is machine generated and an opaque byte sequence
Expand Down Expand Up @@ -110,7 +110,7 @@ pub struct Item<E = ()> {
pub extensions: Option<Vec<Extension<E>>>, // default []
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "kebab-case")]
pub enum ItemType {
/// An [Item] that SHOULD contain any of the following [Credential] types:
Expand All @@ -133,7 +133,7 @@ pub enum ItemType {
Unknown(String),
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct LinkedItem {
/// The [Item’s id][Item::id] that this [LinkedItem] refers to. Note that this [Item] might not
/// be sent as part of the current exchange.
Expand All @@ -145,7 +145,7 @@ pub struct LinkedItem {
pub account: Option<B64Url>,
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(tag = "name", rename_all = "kebab-case")]
pub enum Extension<E = ()> {
#[serde(untagged)]
Expand All @@ -154,7 +154,7 @@ pub enum Extension<E = ()> {
Unknown(serde_json::Value),
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "kebab-case")]
pub enum Credential {
BasicAuth(BasicAuthCredential),
Expand Down Expand Up @@ -194,7 +194,7 @@ pub enum Credential {
},
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BasicAuthCredential {
pub urls: Vec<Uri>,
Expand All @@ -204,7 +204,7 @@ pub struct BasicAuthCredential {
pub password: Option<EditableField>,
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PasskeyCredential {
pub credential_id: B64Url,
Expand All @@ -217,7 +217,7 @@ pub struct PasskeyCredential {
pub fido2_extensions: Option<Fido2Extensions>,
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum OTPHashAlgorithm {
Sha1,
Expand All @@ -227,7 +227,7 @@ pub enum OTPHashAlgorithm {
Unknown(String),
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EditableField {
/// A unique identifier for the [EditableField] which is machine generated and an opaque byte
Expand All @@ -251,7 +251,7 @@ pub struct EditableField {
pub label: Option<String>,
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "kebab-case")]
pub enum FieldType {
/// A UTF-8 encoded string value which is unconcealed and does not have a specified format.
Expand Down
8 changes: 4 additions & 4 deletions credential-exchange-types/src/format/passkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};

use crate::b64url::B64Url;

#[derive(Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Fido2Extensions {
#[serde(default, skip_serializing_if = "Option::is_none")]
Expand All @@ -17,22 +17,22 @@ pub struct Fido2Extensions {
pub supplemental_keys: Option<Fido2SupplementalKeys>,
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Fido2HmacSecret {
pub alias: String,
pub hmac_secret: B64Url,
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Fido2LargeBlob {
pub size: u64,
pub alg: String,
pub data: B64Url,
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Fido2SupplementalKeys {
#[serde(default, skip_serializing_if = "Option::is_none")]
Expand Down