13 lines · 553 BRaw
| 1 | import cli from "../../cli/refs.mjs?raw"; |
| 2 | |
| 3 | let checksum: Promise<string> | undefined; |
| 4 | |
| 5 | async function sha256(text: string): Promise<string> { |
| 6 | const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(text)); |
| 7 | return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join(""); |
| 8 | } |
| 9 | |
| 10 | export async function loader() { |
| 11 | checksum ??= sha256(cli); |
| 12 | return new Response(cli, { headers: { "content-type": "text/javascript; charset=utf-8", "cache-control": "no-cache", "x-refs-sha256": await checksum } }); |
| 13 | } |