text stringlengths 70 351k | source stringclasses 4
values |
|---|---|
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type.rs | crate: common_utils
fn test_invalid_ref_id_length_error_type() {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type.rs | crate: common_utils
fn test_invalid_ref_id_length() {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type.rs | crate: common_utils
fn test_invalid_ref_id_error_message() {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type.rs | crate: common_utils
fn test_invalid_ref_id() {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type.rs | crate: common_utils
fn test_valid_reference_id() {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type.rs | crate: common_utils
fn test_id_deserialize_with_emojis() {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type.rs | crate: common_utils
fn test_id_deserialize_with_spaces() {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type.rs | crate: common_utils
fn test_id_deserialize_hyphen() {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type.rs | crate: common_utils
fn test_id_deserialize_underscore() {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type.rs | crate: common_utils
use diesel::{
backend::Backend,
deserialize::FromSql,
expression::AsExpression,
serialize::{Output, ToSql},
sql_types,
};
fn from_sql(value: DB::RawValue<'_>) -> diesel::deserialize::Result<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type.rs | crate: common_utils
pub use self::global_id::{
customer::GlobalCustomerId,
payment::{GlobalAttemptId, GlobalPaymentId},
payment_methods::{GlobalPaymentMethodId, GlobalPaymentMethodSessionId},
refunds::GlobalRefundId,
CellId,
};
pub use self::{
api_key::ApiKeyId,
client_secret::ClientSecretId,
customer::CustomerId,
merchant::MerchantId,
merchant_connector_account::MerchantConnectorAccountId,
organization::OrganizationId,
payment::{PaymentId, PaymentReferenceId},
profile::ProfileId,
refunds::RefundReferenceId,
relay::RelayId,
routing::RoutingId,
tenant::TenantId,
};
use crate::{fp_utils::when, generate_id_with_default_len};
/// Create a new LengthId from aplhanumeric id
pub(crate) fn from_alphanumeric_id(
alphanumeric_id: AlphaNumericId,
) -> Result<Self, LengthIdError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type.rs | crate: common_utils
pub use self::global_id::{
customer::GlobalCustomerId,
payment::{GlobalAttemptId, GlobalPaymentId},
payment_methods::{GlobalPaymentMethodId, GlobalPaymentMethodSessionId},
refunds::GlobalRefundId,
CellId,
};
pub use self::{
api_key::ApiKeyId,
client_secret::ClientSecretId,
customer::CustomerId,
merchant::MerchantId,
merchant_connector_account::MerchantConnectorAccountId,
organization::OrganizationId,
payment::{PaymentId, PaymentReferenceId},
profile::ProfileId,
refunds::RefundReferenceId,
relay::RelayId,
routing::RoutingId,
tenant::TenantId,
};
use crate::{fp_utils::when, generate_id_with_default_len};
/// Use this function only if you are sure that the length is within the range
pub(crate) fn new_unchecked(alphanumeric_id: AlphaNumericId) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type.rs | crate: common_utils
pub use self::global_id::{
customer::GlobalCustomerId,
payment::{GlobalAttemptId, GlobalPaymentId},
payment_methods::{GlobalPaymentMethodId, GlobalPaymentMethodSessionId},
refunds::GlobalRefundId,
CellId,
};
pub use self::{
api_key::ApiKeyId,
client_secret::ClientSecretId,
customer::CustomerId,
merchant::MerchantId,
merchant_connector_account::MerchantConnectorAccountId,
organization::OrganizationId,
payment::{PaymentId, PaymentReferenceId},
profile::ProfileId,
refunds::RefundReferenceId,
relay::RelayId,
routing::RoutingId,
tenant::TenantId,
};
/// Generate a new MerchantRefId of default length with the given prefix
pub fn new(prefix: &str) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type.rs | crate: common_utils
use std::{borrow::Cow, fmt::Debug};
pub use self::global_id::{
customer::GlobalCustomerId,
payment::{GlobalAttemptId, GlobalPaymentId},
payment_methods::{GlobalPaymentMethodId, GlobalPaymentMethodSessionId},
refunds::GlobalRefundId,
CellId,
};
pub use self::{
api_key::ApiKeyId,
client_secret::ClientSecretId,
customer::CustomerId,
merchant::MerchantId,
merchant_connector_account::MerchantConnectorAccountId,
organization::OrganizationId,
payment::{PaymentId, PaymentReferenceId},
profile::ProfileId,
refunds::RefundReferenceId,
relay::RelayId,
routing::RoutingId,
tenant::TenantId,
};
use crate::{fp_utils::when, generate_id_with_default_len};
/// Generates new [MerchantReferenceId] from the given input string
pub fn from(input_string: Cow<'static, str>) -> Result<Self, LengthIdError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type.rs | crate: common_utils
fn from(alphanumeric_id_error: AlphaNumericIdError) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type.rs | crate: common_utils
pub use self::global_id::{
customer::GlobalCustomerId,
payment::{GlobalAttemptId, GlobalPaymentId},
payment_methods::{GlobalPaymentMethodId, GlobalPaymentMethodSessionId},
refunds::GlobalRefundId,
CellId,
};
pub use self::{
api_key::ApiKeyId,
client_secret::ClientSecretId,
customer::CustomerId,
merchant::MerchantId,
merchant_connector_account::MerchantConnectorAccountId,
organization::OrganizationId,
payment::{PaymentId, PaymentReferenceId},
profile::ProfileId,
refunds::RefundReferenceId,
relay::RelayId,
routing::RoutingId,
tenant::TenantId,
};
use crate::{fp_utils::when, generate_id_with_default_len};
/// Generate a new alphanumeric id of default length
pub(crate) fn new(prefix: &str) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type.rs | crate: common_utils
pub use self::global_id::{
customer::GlobalCustomerId,
payment::{GlobalAttemptId, GlobalPaymentId},
payment_methods::{GlobalPaymentMethodId, GlobalPaymentMethodSessionId},
refunds::GlobalRefundId,
CellId,
};
pub use self::{
api_key::ApiKeyId,
client_secret::ClientSecretId,
customer::CustomerId,
merchant::MerchantId,
merchant_connector_account::MerchantConnectorAccountId,
organization::OrganizationId,
payment::{PaymentId, PaymentReferenceId},
profile::ProfileId,
refunds::RefundReferenceId,
relay::RelayId,
routing::RoutingId,
tenant::TenantId,
};
use crate::{fp_utils::when, generate_id_with_default_len};
/// Create a new alphanumeric id without any validations
pub(crate) fn new_unchecked(input_string: String) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type.rs | crate: common_utils
use std::{borrow::Cow, fmt::Debug};
pub use self::global_id::{
customer::GlobalCustomerId,
payment::{GlobalAttemptId, GlobalPaymentId},
payment_methods::{GlobalPaymentMethodId, GlobalPaymentMethodSessionId},
refunds::GlobalRefundId,
CellId,
};
pub use self::{
api_key::ApiKeyId,
client_secret::ClientSecretId,
customer::CustomerId,
merchant::MerchantId,
merchant_connector_account::MerchantConnectorAccountId,
organization::OrganizationId,
payment::{PaymentId, PaymentReferenceId},
profile::ProfileId,
refunds::RefundReferenceId,
relay::RelayId,
routing::RoutingId,
tenant::TenantId,
};
/// Creates a new alphanumeric id from string by applying validation checks
pub fn from(input_string: Cow<'static, str>) -> Result<Self, AlphaNumericIdError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/common_utils/src/id_type.rs | crate: common_utils
use diesel::{
backend::Backend,
deserialize::FromSql,
expression::AsExpression,
serialize::{Output, ToSql},
sql_types,
};
use serde::{Deserialize, Serialize};
use thiserror::Error;
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let deserialized_string = String::deserialize(deserializer)?;
Self::from(deserialized_string.into()).map_err(serde::de::Error::custom)
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type.rs | crate: common_utils
use std::{borrow::Cow, fmt::Debug};
/// This functions checks for the input string to contain valid characters
/// Returns Some(char) if there are any invalid characters, else None
fn get_invalid_input_character(input_string: Cow<'static, str>) -> Option<char> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type.rs | crate: common_utils
fn is_valid_id_character(input_char: char) -> bool {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use masking::{ExposeInterface, Secret};
use ring::{
aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey},
hmac,
};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
pub type OptionalEncryptableSecretString = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableName = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableEmail = Option<Encryptable<Secret<String, pii::EmailStrategy>>>;
pub type OptionalEncryptablePhone = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableValue = Option<Encryptable<Secret<serde_json::Value>>>;
pub type OptionalSecretValue = Option<Secret<serde_json::Value>>;
pub type EncryptableName = Encryptable<Secret<String>>;
pub type EncryptableEmail = Encryptable<Secret<String, pii::EmailStrategy>>;
fn decode_message(
&self,
secret: &[u8],
msg: Secret<Vec<u8>, EncryptionStrategy>,
) -> CustomResult<Vec<u8>, errors::CryptoError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use ring::{
aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey},
hmac,
};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
fn sign_message(
&self,
_secret: &[u8],
_msg: &[u8],
) -> CustomResult<Vec<u8>, errors::CryptoError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
fn test_md5_verify_signature() {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
fn test_md5_digest() {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
pub type OptionalEncryptableSecretString = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableName = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableEmail = Option<Encryptable<Secret<String, pii::EmailStrategy>>>;
pub type OptionalEncryptablePhone = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableValue = Option<Encryptable<Secret<serde_json::Value>>>;
pub type OptionalSecretValue = Option<Secret<serde_json::Value>>;
pub type EncryptableName = Encryptable<Secret<String>>;
pub type EncryptableEmail = Encryptable<Secret<String, pii::EmailStrategy>>;
fn test_hmac_sha512_verify_signature() {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
pub type OptionalEncryptableSecretString = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableName = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableEmail = Option<Encryptable<Secret<String, pii::EmailStrategy>>>;
pub type OptionalEncryptablePhone = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableValue = Option<Encryptable<Secret<serde_json::Value>>>;
pub type OptionalSecretValue = Option<Secret<serde_json::Value>>;
pub type EncryptableName = Encryptable<Secret<String>>;
pub type EncryptableEmail = Encryptable<Secret<String, pii::EmailStrategy>>;
fn test_hmac_sha512_sign_message() {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
fn test_sha256_verify_signature() {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
pub type OptionalEncryptableSecretString = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableName = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableEmail = Option<Encryptable<Secret<String, pii::EmailStrategy>>>;
pub type OptionalEncryptablePhone = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableValue = Option<Encryptable<Secret<serde_json::Value>>>;
pub type OptionalSecretValue = Option<Secret<serde_json::Value>>;
pub type EncryptableName = Encryptable<Secret<String>>;
pub type EncryptableEmail = Encryptable<Secret<String, pii::EmailStrategy>>;
fn test_hmac_sha256_verify_signature() {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
pub type OptionalEncryptableSecretString = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableName = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableEmail = Option<Encryptable<Secret<String, pii::EmailStrategy>>>;
pub type OptionalEncryptablePhone = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableValue = Option<Encryptable<Secret<serde_json::Value>>>;
pub type OptionalSecretValue = Option<Secret<serde_json::Value>>;
pub type EncryptableName = Encryptable<Secret<String>>;
pub type EncryptableEmail = Encryptable<Secret<String, pii::EmailStrategy>>;
fn test_hmac_sha256_sign_message() {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use ring::{
aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey},
hmac,
};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
pub type OptionalEncryptableSecretString = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableName = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableEmail = Option<Encryptable<Secret<String, pii::EmailStrategy>>>;
pub type OptionalEncryptablePhone = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableValue = Option<Encryptable<Secret<serde_json::Value>>>;
pub type OptionalSecretValue = Option<Secret<serde_json::Value>>;
pub type EncryptableName = Encryptable<Secret<String>>;
pub type EncryptableEmail = Encryptable<Secret<String, pii::EmailStrategy>>;
/// consume self and modify the inner value
pub fn map<U: Clone>(self, f: impl FnOnce(T) -> U) -> Encryptable<U> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use ring::{
aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey},
hmac,
};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
pub type OptionalEncryptableSecretString = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableName = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableEmail = Option<Encryptable<Secret<String, pii::EmailStrategy>>>;
pub type OptionalEncryptablePhone = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableValue = Option<Encryptable<Secret<serde_json::Value>>>;
pub type OptionalSecretValue = Option<Secret<serde_json::Value>>;
pub type EncryptableName = Encryptable<Secret<String>>;
pub type EncryptableEmail = Encryptable<Secret<String, pii::EmailStrategy>>;
/// Deserialize inner value and return new Encryptable object
pub fn deserialize_inner_value<U, F>(
self,
f: F,
) -> CustomResult<Encryptable<U>, errors::ParsingError>
where
F: FnOnce(T) -> CustomResult<U, errors::ParsingError>,
U: Clone,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use masking::{ExposeInterface, Secret};
use ring::{
aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey},
hmac,
};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
pub type OptionalEncryptableSecretString = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableName = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableEmail = Option<Encryptable<Secret<String, pii::EmailStrategy>>>;
pub type OptionalEncryptablePhone = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableValue = Option<Encryptable<Secret<serde_json::Value>>>;
pub type OptionalSecretValue = Option<Secret<serde_json::Value>>;
pub type EncryptableName = Encryptable<Secret<String>>;
pub type EncryptableEmail = Encryptable<Secret<String, pii::EmailStrategy>>;
pub fn into_encrypted(self) -> Secret<Vec<u8>, EncryptionStrategy> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use ring::{
aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey},
hmac,
};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
pub type OptionalEncryptableSecretString = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableName = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableEmail = Option<Encryptable<Secret<String, pii::EmailStrategy>>>;
pub type OptionalEncryptablePhone = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableValue = Option<Encryptable<Secret<serde_json::Value>>>;
pub type OptionalSecretValue = Option<Secret<serde_json::Value>>;
pub type EncryptableName = Encryptable<Secret<String>>;
pub type EncryptableEmail = Encryptable<Secret<String, pii::EmailStrategy>>;
pub fn into_inner(self) -> T {
self.inner
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use masking::{ExposeInterface, Secret};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
pub type OptionalEncryptableSecretString = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableName = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableEmail = Option<Encryptable<Secret<String, pii::EmailStrategy>>>;
pub type OptionalEncryptablePhone = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableValue = Option<Encryptable<Secret<serde_json::Value>>>;
pub type OptionalSecretValue = Option<Secret<serde_json::Value>>;
pub type EncryptableName = Encryptable<Secret<String>>;
pub type EncryptableEmail = Encryptable<Secret<String, pii::EmailStrategy>>;
/// constructor function to be used by the encryptor and decryptor to generate the data type
pub fn new(
masked_data: Secret<T, S>,
encrypted_data: Secret<Vec<u8>, EncryptionStrategy>,
) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use std::ops::Deref;
use error_stack::ResultExt;
use masking::{ExposeInterface, Secret};
use md5;
use ring::{
aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey},
hmac,
};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
pub type OptionalEncryptableSecretString = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableName = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableEmail = Option<Encryptable<Secret<String, pii::EmailStrategy>>>;
pub type OptionalEncryptablePhone = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableValue = Option<Encryptable<Secret<serde_json::Value>>>;
pub type OptionalSecretValue = Option<Secret<serde_json::Value>>;
pub type EncryptableName = Encryptable<Secret<String>>;
pub type EncryptableEmail = Encryptable<Secret<String, pii::EmailStrategy>>;
pub fn generate_cryptographically_secure_random_bytes<const N: usize>() -> [u8; N] {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use std::ops::Deref;
use error_stack::ResultExt;
use masking::{ExposeInterface, Secret};
use md5;
use ring::{
aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey},
hmac,
};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
pub type OptionalEncryptableSecretString = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableName = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableEmail = Option<Encryptable<Secret<String, pii::EmailStrategy>>>;
pub type OptionalEncryptablePhone = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableValue = Option<Encryptable<Secret<serde_json::Value>>>;
pub type OptionalSecretValue = Option<Secret<serde_json::Value>>;
pub type EncryptableName = Encryptable<Secret<String>>;
pub type EncryptableEmail = Encryptable<Secret<String, pii::EmailStrategy>>;
pub fn generate_cryptographically_secure_random_string(length: usize) -> String {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use ring::{
aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey},
hmac,
};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
fn encode_message(
&self,
secret: &[u8],
msg: &[u8],
) -> CustomResult<Vec<u8>, errors::CryptoError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
pub type OptionalEncryptableSecretString = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableName = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableEmail = Option<Encryptable<Secret<String, pii::EmailStrategy>>>;
pub type OptionalEncryptablePhone = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableValue = Option<Encryptable<Secret<serde_json::Value>>>;
pub type OptionalSecretValue = Option<Secret<serde_json::Value>>;
pub type EncryptableName = Encryptable<Secret<String>>;
pub type EncryptableEmail = Encryptable<Secret<String, pii::EmailStrategy>>;
/// Constructor function to be used by the encryptor and decryptor to generate the data type
pub fn new(
padding: Option<common_enums::CryptoPadding>,
iv: Vec<u8>,
) -> Result<Self, errors::CryptoError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use ring::{
aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey},
hmac,
};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
fn verify_signature(
&self,
_secret: &[u8],
signature: &[u8],
msg: &[u8],
) -> CustomResult<bool, errors::CryptoError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use ring::{
aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey},
hmac,
};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
fn verify_signature(
&self,
_secret: &[u8],
signature: &[u8],
msg: &[u8],
) -> CustomResult<bool, errors::CryptoError> {
let hashed_digest = Self
.generate_digest(msg)
.change_context(errors::CryptoError::SignatureVerificationFailed)?;
Ok(hashed_digest == signature)
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use md5;
use ring::{
aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey},
hmac,
};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
fn generate_digest(&self, message: &[u8]) -> CustomResult<Vec<u8>, errors::CryptoError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use ring::{
aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey},
hmac,
};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
fn encode_message(
&self,
secret: &[u8],
msg: &[u8],
) -> CustomResult<Vec<u8>, errors::CryptoError> {
let nonce_sequence =
NonceSequence::new().change_context(errors::CryptoError::EncodingFailed)?;
let current_nonce = nonce_sequence.current();
let key = UnboundKey::new(&aead::AES_256_GCM, secret)
.change_context(errors::CryptoError::EncodingFailed)?;
let mut key = SealingKey::new(key, nonce_sequence);
let mut in_out = msg.to_vec();
key.seal_in_place_append_tag(aead::Aad::empty(), &mut in_out)
.change_context(errors::CryptoError::EncodingFailed)?;
in_out.splice(0..0, current_nonce);
Ok(in_out)
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use ring::{
aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey},
hmac,
};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
fn verify_signature(
&self,
secret: &[u8],
signature: &[u8],
msg: &[u8],
) -> CustomResult<bool, errors::CryptoError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use ring::{
aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey},
hmac,
};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
fn sign_message(
&self,
secret: &[u8],
msg: &[u8],
) -> CustomResult<Vec<u8>, errors::CryptoError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
pub type OptionalEncryptableSecretString = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableName = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableEmail = Option<Encryptable<Secret<String, pii::EmailStrategy>>>;
pub type OptionalEncryptablePhone = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableValue = Option<Encryptable<Secret<serde_json::Value>>>;
pub type OptionalSecretValue = Option<Secret<serde_json::Value>>;
pub type EncryptableName = Encryptable<Secret<String>>;
pub type EncryptableEmail = Encryptable<Secret<String, pii::EmailStrategy>>;
/// Create a new instance of Blake3 with a key
pub fn new(key: impl Into<String>) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use ring::{
aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey},
hmac,
};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
fn sign_message(
&self,
secret: &[u8],
msg: &[u8],
) -> CustomResult<Vec<u8>, errors::CryptoError> {
let key = hmac::Key::new(hmac::HMAC_SHA256, secret);
Ok(hmac::sign(&key, msg).as_ref().to_vec())
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use masking::{ExposeInterface, Secret};
use ring::{
aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey},
hmac,
};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
pub type OptionalEncryptableSecretString = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableName = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableEmail = Option<Encryptable<Secret<String, pii::EmailStrategy>>>;
pub type OptionalEncryptablePhone = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableValue = Option<Encryptable<Secret<serde_json::Value>>>;
pub type OptionalSecretValue = Option<Secret<serde_json::Value>>;
pub type EncryptableName = Encryptable<Secret<String>>;
pub type EncryptableEmail = Encryptable<Secret<String, pii::EmailStrategy>>;
fn decode_message(
&self,
_secret: &[u8],
msg: Secret<Vec<u8>, EncryptionStrategy>,
) -> CustomResult<Vec<u8>, errors::CryptoError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use ring::{
aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey},
hmac,
};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
fn encode_message(
&self,
_secret: &[u8],
msg: &[u8],
) -> CustomResult<Vec<u8>, errors::CryptoError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use ring::{
aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey},
hmac,
};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
fn verify_signature(
&self,
_secret: &[u8],
_signature: &[u8],
_msg: &[u8],
) -> CustomResult<bool, errors::CryptoError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use ring::{
aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey},
hmac,
};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
fn sign_message(
&self,
_secret: &[u8],
_msg: &[u8],
) -> CustomResult<Vec<u8>, errors::CryptoError> {
Ok(Vec::new())
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/crypto.rs | crate: common_utils
use ring::{
aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey},
hmac,
};
use crate::{
errors::{self, CustomResult},
pii::{self, EncryptionStrategy},
};
fn advance(&mut self) -> Result<aead::Nonce, ring::error::Unspecified> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/custom_serde.rs | crate: common_utils
fn test_leap_second_parse() {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/custom_serde.rs | crate: common_utils
/// Serialize a type to json_string format
pub fn serialize<T, S>(value: &T, serializer: S) -> Result<S::Ok, S::Error>
where
T: Serialize,
S: Serializer,
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/common_utils/src/custom_serde.rs | crate: common_utils
fn test_leap_second_parse() {
#[derive(Serialize, Deserialize)]
struct Try {
#[serde(with = "crate::custom_serde::iso8601")]
f: time::PrimitiveDateTime,
}
let leap_second_date_time = json!({"f": "2023-12-31T23:59:60.000Z"});
let deser = serde_json::from_value::<Try>(leap_second_date_time);
assert!(deser.is_ok())
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/custom_serde.rs | crate: common_utils
/// Deserialize an [`PrimitiveDateTime`] from its ISO 8601 representation.
pub fn deserialize<'a, D>(deserializer: D) -> Result<PrimitiveDateTime, D::Error>
where
D: Deserializer<'a>,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/custom_serde.rs | crate: common_utils
/// Deserialize a string which is in json format
pub fn deserialize<'de, T, D>(deserializer: D) -> Result<T, D::Error>
where
T: DeserializeOwned,
D: Deserializer<'de>,
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/common_utils/src/custom_serde.rs | crate: common_utils
/// Serialize a type to json_string format
pub fn serialize<T, S>(value: &T, serializer: S) -> Result<S::Ok, S::Error>
where
T: Serialize,
S: Serializer,
{
let j = serde_json::to_string(value).map_err(ser::Error::custom)?;
j.serialize(serializer)
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/custom_serde.rs | crate: common_utils
/// Deserialize an [`Option<PrimitiveDateTime>`] from UNIX timestamp.
pub fn deserialize<'a, D>(deserializer: D) -> Result<Option<PrimitiveDateTime>, D::Error>
where
D: Deserializer<'a>,
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/custom_serde.rs | crate: common_utils
/// Serialize an [`Option<PrimitiveDateTime>`] from UNIX timestamp.
pub fn serialize<S>(
date_time: &Option<PrimitiveDateTime>,
serializer: S,
) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/custom_serde.rs | crate: common_utils
/// Deserialize an [`PrimitiveDateTime`] from UNIX timestamp.
pub fn deserialize<'a, D>(deserializer: D) -> Result<PrimitiveDateTime, D::Error>
where
D: Deserializer<'a>,
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/common_utils/src/custom_serde.rs | crate: common_utils
/// Serialize a [`PrimitiveDateTime`] using UNIX timestamp.
pub fn serialize<S>(date_time: &PrimitiveDateTime, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
date_time
.assume_utc()
.unix_timestamp()
.serialize(serializer)
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/custom_serde.rs | crate: common_utils
/// Deserialize an [`Option<PrimitiveDateTime>`] from its ISO 8601 representation.
pub fn deserialize<'a, D>(deserializer: D) -> Result<Option<PrimitiveDateTime>, D::Error>
where
D: Deserializer<'a>,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/custom_serde.rs | crate: common_utils
/// Serialize an [`Option<PrimitiveDateTime>`] using the well-known ISO 8601 format which is without timezone.
pub fn serialize<S>(
date_time: &Option<PrimitiveDateTime>,
serializer: S,
) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/common_utils/src/custom_serde.rs | crate: common_utils
/// Serialize an [`Option<PrimitiveDateTime>`] using the well-known ISO 8601 format.
pub fn serialize<S>(
date_time: &Option<PrimitiveDateTime>,
serializer: S,
) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
date_time
.map(|date_time| date_time.assume_utc().format(&Iso8601::<FORMAT_CONFIG>))
.transpose()
.map_err(S::Error::custom)?
.serialize(serializer)
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/custom_serde.rs | crate: common_utils
/// Serialize a [`PrimitiveDateTime`] using the well-known ISO 8601 format.
pub fn serialize<S>(date_time: &PrimitiveDateTime, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/types/keymanager.rs | crate: common_utils
use masking::{ExposeInterface, PeekInterface, Secret, Strategy, StrongSecret};
use rustc_hash::FxHashMap;
fn from(
(map, identifier): (FxHashMap<String, Secret<serde_json::Value, S>>, Identifier),
) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/types/keymanager.rs | crate: common_utils
use masking::{ExposeInterface, PeekInterface, Secret, Strategy, StrongSecret};
fn from((secret, identifier): (Secret<Vec<u8>, S>, Identifier)) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/types/keymanager.rs | crate: common_utils
use masking::{ExposeInterface, PeekInterface, Secret, Strategy, StrongSecret};
pub fn from_data(data: StrongSecret<Vec<u8>>) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/types/keymanager.rs | crate: common_utils
use serde::{
de::{self, Unexpected, Visitor},
ser, Deserialize, Deserializer, Serialize,
};
use crate::{
consts::BASE64_ENGINE,
crypto::Encryptable,
encryption::Encryption,
errors::{self, CustomResult},
id_type,
transformers::{ForeignFrom, ForeignTryFrom},
};
fn visit_str<E>(self, value: &str) -> Result<DecryptedData, E>
where
E: de::Error,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/types/keymanager.rs | crate: common_utils
use masking::{ExposeInterface, PeekInterface, Secret, Strategy, StrongSecret};
use rustc_hash::FxHashMap;
use crate::{
consts::BASE64_ENGINE,
crypto::Encryptable,
encryption::Encryption,
errors::{self, CustomResult},
id_type,
transformers::{ForeignFrom, ForeignTryFrom},
};
fn from((map, identifier): (FxHashMap<String, Encryption>, Identifier)) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/types/keymanager.rs | crate: common_utils
use masking::{ExposeInterface, PeekInterface, Secret, Strategy, StrongSecret};
use crate::{
consts::BASE64_ENGINE,
crypto::Encryptable,
encryption::Encryption,
errors::{self, CustomResult},
id_type,
transformers::{ForeignFrom, ForeignTryFrom},
};
fn from((encryption, identifier): (Encryption, Identifier)) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/types/keymanager.rs | crate: common_utils
use rustc_hash::FxHashMap;
use crate::{
consts::BASE64_ENGINE,
crypto::Encryptable,
encryption::Encryption,
errors::{self, CustomResult},
id_type,
transformers::{ForeignFrom, ForeignTryFrom},
};
fn foreign_try_from(
(mut encrypted_data, response): (FxHashMap<String, Encryption>, BatchDecryptDataResponse),
) -> Result<Self, Self::Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/types/keymanager.rs | crate: common_utils
use crate::{
consts::BASE64_ENGINE,
crypto::Encryptable,
encryption::Encryption,
errors::{self, CustomResult},
id_type,
transformers::{ForeignFrom, ForeignTryFrom},
};
fn foreign_try_from(
(encrypted_data, response): (Encryption, DecryptDataResponse),
) -> Result<Self, Self::Error> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/types/keymanager.rs | crate: common_utils
use masking::{ExposeInterface, PeekInterface, Secret, Strategy, StrongSecret};
use crate::{
consts::BASE64_ENGINE,
crypto::Encryptable,
encryption::Encryption,
errors::{self, CustomResult},
id_type,
transformers::{ForeignFrom, ForeignTryFrom},
};
fn convert(
value: &DecryptedData,
encryption: Encryption,
) -> CustomResult<Self, errors::CryptoError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/types/keymanager.rs | crate: common_utils
use masking::{ExposeInterface, PeekInterface, Secret, Strategy, StrongSecret};
fn foreign_from((masked_data, response): (Secret<T, S>, EncryptDataResponse)) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/types/keymanager.rs | crate: common_utils
use masking::{ExposeInterface, PeekInterface, Secret, Strategy, StrongSecret};
use rustc_hash::FxHashMap;
use crate::{
consts::BASE64_ENGINE,
crypto::Encryptable,
encryption::Encryption,
errors::{self, CustomResult},
id_type,
transformers::{ForeignFrom, ForeignTryFrom},
};
fn foreign_from(
(mut masked_data, response): (FxHashMap<String, Secret<T, S>>, BatchEncryptDataResponse),
) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/types/keymanager.rs | crate: common_utils
use masking::{ExposeInterface, PeekInterface, Secret, Strategy, StrongSecret};
use rustc_hash::FxHashMap;
fn from((map, identifier): (FxHashMap<String, Secret<String, S>>, Identifier)) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/common_utils/src/types/keymanager.rs | crate: common_utils
use masking::{ExposeInterface, PeekInterface, Secret, Strategy, StrongSecret};
use rustc_hash::FxHashMap;
fn from(
(map, identifier): (FxHashMap<String, Secret<serde_json::Value, S>>, Identifier),
) -> Self {
let group = map
.into_iter()
.map(|(key, value)| {
(
key,
DecryptedData(StrongSecret::new(
value.expose().to_string().as_bytes().to_vec(),
)),
)
})
.collect();
Self {
data: DecryptedDataGroup(group),
identifier,
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/types/keymanager.rs | crate: common_utils
use masking::{ExposeInterface, PeekInterface, Secret, Strategy, StrongSecret};
fn from((secret, identifier): (Secret<serde_json::Value, S>, Identifier)) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/types/keymanager.rs | crate: common_utils
use masking::{ExposeInterface, PeekInterface, Secret, Strategy, StrongSecret};
fn from((secret, identifier): (Secret<String, S>, Identifier)) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/types/keymanager.rs | crate: common_utils
use masking::{ExposeInterface, PeekInterface, Secret, Strategy, StrongSecret};
use rustc_hash::FxHashMap;
fn from((map, identifier): (FxHashMap<String, Secret<Vec<u8>, S>>, Identifier)) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/common_utils/src/types/keymanager.rs | crate: common_utils
use masking::{ExposeInterface, PeekInterface, Secret, Strategy, StrongSecret};
fn from((secret, identifier): (Secret<Vec<u8>, S>, Identifier)) -> Self {
Self {
identifier,
data: DecryptedData(StrongSecret::new(secret.expose())),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type/tenant.rs | crate: common_utils
use crate::{
consts::DEFAULT_GLOBAL_TENANT_ID,
errors::{CustomResult, ValidationError},
};
/// Get tenant id from String
pub fn try_from_string(tenant_id: String) -> CustomResult<Self, ValidationError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/common_utils/src/id_type/tenant.rs | crate: common_utils
use crate::{
consts::DEFAULT_GLOBAL_TENANT_ID,
errors::{CustomResult, ValidationError},
};
/// Get tenant id from String
pub fn try_from_string(tenant_id: String) -> CustomResult<Self, ValidationError> {
Self::try_from(std::borrow::Cow::from(tenant_id))
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type/tenant.rs | crate: common_utils
use crate::{
consts::DEFAULT_GLOBAL_TENANT_ID,
errors::{CustomResult, ValidationError},
};
/// Get the default global tenant ID
pub fn get_default_global_tenant_id() -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type/merchant.rs | crate: common_utils
/// get_payment_config_routing_id
pub fn get_payment_config_routing_id(&self) -> String {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type/merchant.rs | crate: common_utils
/// get_blocklist_enabled_key
pub fn get_blocklist_guard_key(&self) -> String {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type/merchant.rs | crate: common_utils
/// get_max_auto_single_connector_payout_retries_enabled_
pub fn get_max_auto_single_connector_payout_retries_enabled(
&self,
payout_retry_type: common_enums::PayoutRetryType,
) -> String {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type/merchant.rs | crate: common_utils
/// Get should call gsm key for payment
pub fn get_should_call_gsm_key(&self) -> String {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type/merchant.rs | crate: common_utils
/// get_should_call_gsm_payout_key
pub fn get_should_call_gsm_payout_key(
&self,
payout_retry_type: common_enums::PayoutRetryType,
) -> String {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type/merchant.rs | crate: common_utils
/// get_webhook_config_disabled_events_key
pub fn get_webhook_config_disabled_events_key(&self, connector_id: &str) -> String {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type/merchant.rs | crate: common_utils
/// get_payment_method_surcharge_routing_id
pub fn get_payment_method_surcharge_routing_id(&self) -> String {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/common_utils/src/id_type/merchant.rs | crate: common_utils
/// get_payment_config_routing_id
pub fn get_payment_config_routing_id(&self) -> String {
format!("payment_config_id_{}", self.get_string_repr())
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type/merchant.rs | crate: common_utils
/// get_skip_saving_wallet_at_connector_key
pub fn get_skip_saving_wallet_at_connector_key(&self) -> String {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type/merchant.rs | crate: common_utils
use std::fmt::Display;
/// get_access_token_key
pub fn get_access_token_key(
&self,
merchant_connector_id_or_connector_name: impl Display,
) -> String {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type/merchant.rs | crate: common_utils
/// get_poll_id
pub fn get_poll_id(&self, unique_id: &str) -> String {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type/merchant.rs | crate: common_utils
/// get_creds_identifier_key
pub fn get_creds_identifier_key(&self, creds_identifier: &str) -> String {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type/merchant.rs | crate: common_utils
/// get_dsk_key
pub fn get_dsl_config(&self) -> String {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/common_utils/src/id_type/merchant.rs | crate: common_utils
/// get_surcharge_dsk_key
pub fn get_surcharge_dsk_key(&self) -> String {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.