paste-free.openapps.xyz

Source

This app’s code and revision history are public. Download a copy or explore the files below.

Public
The app’s code and revision history are public.
Owned app · rev 01fdb2b1f66e
Run it yourself
Take the whole tree and run it on your own machine. The download needs no account. Cloning needs a sign-in.
Download .zip
bounded clone 6eca480d6447d873e2e5eed9
A copy you download is not bounded. The guarantees this app runs under - declared egress, proven invariants, writes that fail closed - live in the runtime serving this page, not in the files. What you get is auditable source you can read and run, with no runtime guarantees attached.
← All files
src/lib/mine.ts
// The pastes this browser made or manages, kept in localStorage: id, owner key, and what the list shows.
// A paste encrypted with a key in the link also keeps that key here, so its owner can reopen the full link.
// A password is never kept.
export interface Saved { id: string; key: string; title: string; language: string; createdAt: number; ttl: number; burn: boolean; secret?: string; password?: boolean }

const STORE = "paste:mine";

const isSaved = (s: any): s is Saved => s && typeof s.id === "string" && typeof s.key === "string" && typeof s.createdAt === "number";
export const isExpired = (s: { createdAt: number; ttl: number }) => s.ttl > 0 && s.createdAt + s.ttl <= Date.now() / 1000;

export function savedPastes(): Saved[] {
  try {
    const list = JSON.parse(localStorage.getItem(STORE) || "[]");
    return Array.isArray(list) ? list.filter(isSaved) : [];
  } catch {
    return [];
  }
}

export const savedPaste = (id: string) => savedPastes().find((s) => s.id === id) ?? null;

function write(list: Saved[]) {
  try { localStorage.setItem(STORE, JSON.stringify(list)); } catch { /* storage full or blocked: the list is a convenience */ }
  window.dispatchEvent(new Event("paste:saved"));
}

/** Remembers a paste newest first, or refreshes what the list shows for one already saved. */
export function savePaste(s: Saved) {
  const list = savedPastes();
  const old = list.find((x) => x.id === s.id);
  write(old ? list.map((x) => (x.id === s.id ? { ...x, ...s, secret: s.secret ?? x.secret } : x)) : [s, ...list]);
}

export function forgetPaste(id: string) {
  write(savedPastes().filter((s) => s.id !== id));
}

Change history

Quality pass: password lock, year expiry, line links, text/plain API
01fdb2b1f6 · 4 hours ago
Bounded source sync
fe5788c2d2 · 1 day ago
Bounded source sync
ac6f7dbc95 · 1 day ago
Bounded source sync
0a45926293 · 1 day ago