Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/live/commons/secrets/keys.ts

Open-Source web editor based on Preact, Tailwind and TypeScript. The other side of code.
Go to Latest
import * as live from "https://deno.land/x/live@1.48.5/commons/secrets/keys.ts";

Variables

The overall behavior here is to generate the key in the first use and then use it for the entire environment life (across deployments). Essentially we try to retrieve the key from the memory and then fallback to KV using the following order.

  1. Use the in-memory key variable if available (which means it was retrieved at least once)
  2. If not, try fetch from KV (which means it was generated at least once)
  3. If not available, on KV so it needs to be generated. So we generate a new key and then try to atomically save it on KV. in that way we avoid concurrency of two keys being saved/stored in memory at the same time.
  4. If any transaction error occur so we try to retrieve from KV again and use it for the entire isolate life.