mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 09:07:09 +08:00
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:
22
crates/common_utils/src/hashing.rs
Normal file
22
crates/common_utils/src/hashing.rs
Normal 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)
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user