import { r as encodeBase64 } from "../../../../../base64-CmWvODNW.mjs";

//#region src/astro/routes/api/import/wordpress-plugin/callback.ts
const prerender = false;
const GET = async ({ url, cookies, redirect }) => {
	const siteUrl = url.searchParams.get("site_url");
	const userLogin = url.searchParams.get("user_login");
	const password = url.searchParams.get("password");
	if (!siteUrl || !userLogin || !password) return redirect("/_emdash/admin/import/wordpress?error=auth_rejected");
	const token = encodeBase64(`${userLogin}:${password}`);
	const encodedAuth = encodeBase64(JSON.stringify({
		siteUrl,
		userLogin,
		token,
		timestamp: Date.now()
	}));
	cookies.set("emdash_wp_auth", encodedAuth, {
		path: "/_emdash/",
		maxAge: 300,
		httpOnly: false,
		secure: url.protocol === "https:",
		sameSite: "lax"
	});
	return redirect("/_emdash/admin/import/wordpress?auth=success");
};

//#endregion
export { GET, prerender };
//# sourceMappingURL=callback.mjs.map