Files
dify/api/services/human_input_v2/email_credential_codec.py
8cbb6c0130 feat: HITL IM integration (#44864)
Co-authored-by: zxhlyh <jasonapring2015@outlook.com>
Co-authored-by: JzoNg <jzongcode@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-10-30 02:43:31 +00:00

17 lines
846 B
Python

"""Protect Resend authentication credentials with the shared Channel envelope."""
from core.helper import encrypter
from core.human_input_v2.shared import TenantId
from repositories.human_input_v2.channel_credentials import ChannelEncryptedCredentials
from repositories.human_input_v2.email_channel.entities import ResendCredentials
def seal_email_credentials(tenant_id: TenantId, credentials: ResendCredentials) -> ChannelEncryptedCredentials:
ciphertext = encrypter.encrypt_token(str(tenant_id), credentials.model_dump_json())
return ChannelEncryptedCredentials(ciphertext=ciphertext)
def load_email_credentials(tenant_id: TenantId, envelope: ChannelEncryptedCredentials) -> ResendCredentials:
plaintext = encrypter.decrypt_token(str(tenant_id), envelope.ciphertext)
return ResendCredentials.model_validate_json(plaintext)