Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

846 B
Raw Blame
"""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)