import { env } from "cloudflare:workers"; import { decryptSecret, encryptSecret } from "./crypto"; import { badRequest } from "./errors"; export async function encryptRepoSecret(value: string): Promise<{ ciphertext: string; iv: string }> { if (!env.SECRETS_KEY) throw badRequest("SECRETS_KEY is not configured on this instance"); return encryptSecret(env.SECRETS_KEY, value); } export async function decryptRepoSecret(ciphertext: string, iv: string): Promise { if (!env.SECRETS_KEY) throw badRequest("SECRETS_KEY is not configured on this instance"); return decryptSecret(env.SECRETS_KEY, ciphertext, iv); }