@vitejs/plugin-rsc
Version:
React Server Components (RSC) support for Vite.
20 lines (18 loc) • 1.11 kB
JavaScript
import { r as once } from "./dist-BRSdGcl7.js";
import { a as fromBase64, i as encryptBuffer, n as concatArrayStream, r as decryptBuffer, t as arrayToStream } from "./encryption-utils-6p8t4Xqm.js";
import { n as createFromReadableStream, u as renderToReadableStream } from "./rsc-BIM0wUrP.js";
import encryptionKeySource from "virtual:vite-rsc/encryption-key";
//#region src/utils/encryption-runtime.ts
async function encryptActionBoundArgs(originalValue) {
return encryptBuffer(await concatArrayStream(renderToReadableStream(originalValue)), await getEncryptionKey());
}
async function decryptActionBoundArgs(encrypted) {
const serializedBuffer = await decryptBuffer(await encrypted, await getEncryptionKey());
return createFromReadableStream(arrayToStream(new Uint8Array(serializedBuffer)));
}
const getEncryptionKey = /* @__PURE__ */ once(async () => {
const resolved = await encryptionKeySource();
return await crypto.subtle.importKey("raw", fromBase64(resolved), { name: "AES-GCM" }, true, ["encrypt", "decrypt"]);
});
//#endregion
export { encryptActionBoundArgs as n, decryptActionBoundArgs as t };