Skyvern/skyvern/forge/sdk/encrypt/__init__.py
LawyZheng 02576e5be3
Some checks are pending
Run tests and pre-commit / Run tests and pre-commit hooks (push) Waiting to run
Run tests and pre-commit / Frontend Lint and Build (push) Waiting to run
Publish Fern Docs / run (push) Waiting to run
feat: encrypt org auth tokens with AES (#3104)
2025-08-05 12:36:24 +08:00

26 lines
899 B
Python

from pydantic import BaseModel
from skyvern.forge.sdk.encrypt.base import BaseEncryptor, EncryptMethod
class Encryptor(BaseModel):
def __init__(self) -> None:
self._methods: dict[EncryptMethod, BaseEncryptor] = {}
def add_encrypt_method(self, encrypt_method: BaseEncryptor) -> None:
self._methods[encrypt_method.method()] = encrypt_method
async def encrypt(self, plaintext: str, method: EncryptMethod) -> str:
if method not in self._methods:
raise ValueError(f"encrypt method not registered: {method}")
return await self._methods[method].encrypt(plaintext)
async def decrypt(self, ciphertext: str, method: EncryptMethod) -> str:
if method not in self._methods:
raise ValueError(f"encrypt method not registered: {method}")
return await self._methods[method].decrypt(ciphertext)
encryptor = Encryptor()