core_crypto_ffi/identity/
wire.rs
1#[cfg(target_family = "wasm")]
2use wasm_bindgen::prelude::*;
3
4use crate::{CredentialType, X509Identity};
5
6#[derive(Debug, Clone)]
8#[cfg_attr(
9 target_family = "wasm",
10 wasm_bindgen(getter_with_clone),
11 derive(serde::Serialize, serde::Deserialize),
12 serde(rename_all = "camelCase")
13)]
14#[cfg_attr(not(target_family = "wasm"), derive(uniffi::Record))]
15pub struct WireIdentity {
16 #[cfg_attr(target_family = "wasm", wasm_bindgen(readonly, js_name = clientId))]
18 pub client_id: String,
19 #[cfg_attr(target_family = "wasm", wasm_bindgen(readonly))]
21 pub status: DeviceStatus,
22 #[cfg_attr(target_family = "wasm", wasm_bindgen(readonly))]
24 pub thumbprint: String,
25 #[cfg_attr(target_family = "wasm", wasm_bindgen(js_name = credentialType))]
26 pub credential_type: CredentialType,
27 #[cfg_attr(target_family = "wasm", wasm_bindgen(readonly, js_name = x509Identity))]
28 pub x509_identity: Option<X509Identity>,
29}
30
31impl From<core_crypto::prelude::WireIdentity> for WireIdentity {
32 fn from(i: core_crypto::prelude::WireIdentity) -> Self {
33 Self {
34 client_id: i.client_id,
35 status: i.status.into(),
36 thumbprint: i.thumbprint,
37 credential_type: i.credential_type.into(),
38 x509_identity: i.x509_identity.map(Into::into),
39 }
40 }
41}
42
43#[derive(Debug, Copy, Clone, PartialEq, Eq)]
44#[cfg_attr(target_family = "wasm", wasm_bindgen, derive(serde::Serialize, serde::Deserialize))]
45#[cfg_attr(not(target_family = "wasm"), derive(uniffi::Enum))]
46#[repr(u8)]
47pub enum DeviceStatus {
48 Valid = 1,
50 Expired = 2,
52 Revoked = 3,
54}
55
56impl From<core_crypto::prelude::DeviceStatus> for DeviceStatus {
57 fn from(value: core_crypto::prelude::DeviceStatus) -> Self {
58 match value {
59 core_crypto::prelude::DeviceStatus::Valid => Self::Valid,
60 core_crypto::prelude::DeviceStatus::Expired => Self::Expired,
61 core_crypto::prelude::DeviceStatus::Revoked => Self::Revoked,
62 }
63 }
64}