import CryptoJS from "crypto-js";
/**
 * Encrypts a token object using AES-256 encryption.
 * @param token - The token object containing access_token and refresh_token
 * @param key - The encryption key (e.g., zdeskBusinessId)
 * @returns The encrypted token string (Base64 encoded)
 */
export const encryptToken = (token, key) => {
    const tokenJson = JSON.stringify(token);
    const encrypted = CryptoJS.AES.encrypt(tokenJson, key).toString();
    return encrypted;
};
/**
 * Decrypts an AES-256 encrypted token string back to a token object.
 * @param encryptedToken - The encrypted token string
 * @param key - The decryption key (same key used for encryption)
 * @returns The decrypted token object
 */
export const decryptToken = (encryptedToken, key) => {
    const bytes = CryptoJS.AES.decrypt(encryptedToken, key);
    const decryptedJson = bytes.toString(CryptoJS.enc.Utf8);
    return JSON.parse(decryptedJson);
};
