feat(events): add hashed customer_email and feature_metadata (#5220)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Sandeep Kumar
2024-07-05 20:36:59 +05:30
committed by GitHub
parent 5ebfbaf199
commit ae2a34e02c
13 changed files with 105 additions and 13 deletions

View File

@ -0,0 +1,22 @@
use masking::{PeekInterface, Secret, Strategy};
use serde::{Deserialize, Serialize, Serializer};
#[derive(Clone, Debug, Deserialize)]
/// Represents a hashed string using blake3's hashing strategy.
pub struct HashedString<T: Strategy<String>>(Secret<String, T>);
impl<T: Strategy<String>> Serialize for HashedString<T> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let hashed_value = blake3::hash(self.0.peek().as_bytes()).to_hex();
hashed_value.serialize(serializer)
}
}
impl<T: Strategy<String>> From<Secret<String, T>> for HashedString<T> {
fn from(value: Secret<String, T>) -> Self {
Self(value)
}
}

View File

@ -31,6 +31,8 @@ pub mod static_cache;
pub mod types;
pub mod validation;
/// Used for hashing
pub mod hashing;
#[cfg(feature = "metrics")]
pub mod metrics;

View File

@ -14,6 +14,7 @@ use error_stack::ResultExt;
use masking::{ExposeInterface, Secret, Strategy, WithType};
#[cfg(feature = "logs")]
use router_env::logger;
use serde::Deserialize;
use crate::{
crypto::Encryptable,
@ -205,7 +206,7 @@ where
}
/// Strategy for masking Email
#[derive(Debug)]
#[derive(Debug, Copy, Clone, Deserialize)]
pub enum EmailStrategy {}
impl<T> Strategy<T> for EmailStrategy