@vitejs/plugin-rsc
Version:
React Server Components (RSC) support for Vite.
21 lines (19 loc) • 1.12 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 "../rsc-BRh4PjTs.js";
import { createFromReadableStream, renderToReadableStream } from "../react/rsc.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 { decryptActionBoundArgs, encryptActionBoundArgs };