santa-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 b8b257a837b1
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 c7891873549c9ca1004894b3
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
// What this browser remembers: exchanges it organizes (with their admin keys) and the people it is
// (with their keys), so a returning person finds them on the landing page. Keys stay on this device;
// the admin link and each personal link carry them to another device.
export interface MyExchange { id: string; name: string; key?: string; at: number }
export interface MyPerson { exchangeId: string; pid: string; key: string; name: string; exchangeName: string; at: number }

const EXCHANGES = "santa:exchanges";
const PEOPLE = "santa:people";

function read<T>(key: string): T[] {
  try {
    const list = JSON.parse(localStorage.getItem(key) || "[]");
    return Array.isArray(list) ? list : [];
  } catch {
    return [];
  }
}

export const myExchanges = () => read<MyExchange>(EXCHANGES).filter((x) => x && typeof x.id === "string");
export const myPeople = () => read<MyPerson>(PEOPLE).filter((x) => x && typeof x.pid === "string");

export function rememberExchange(x: Partial<MyExchange> & { id: string }) {
  const list = myExchanges();
  const prev = list.find((e) => e.id === x.id);
  localStorage.setItem(EXCHANGES, JSON.stringify([{ name: "", at: Date.now(), ...prev, ...x }, ...list.filter((e) => e.id !== x.id)].slice(0, 100)));
}

export const ownerKey = (id: string) => myExchanges().find((e) => e.id === id)?.key;

export function rememberPerson(p: Partial<MyPerson> & { exchangeId: string; pid: string; key: string }) {
  const list = myPeople();
  const prev = list.find((x) => x.pid === p.pid);
  localStorage.setItem(PEOPLE, JSON.stringify([{ name: "", exchangeName: "", at: Date.now(), ...prev, ...p }, ...list.filter((x) => x.pid !== p.pid)].slice(0, 200)));
}

export const personKey = (pid: string) => myPeople().find((p) => p.pid === pid)?.key;
export const meIn = (exchangeId: string) => myPeople().find((p) => p.exchangeId === exchangeId);

Change history

Point OpenApps links to openapps.free
b8b257a837 · 18 hours ago
Bind agent address in policy constants
9a72d0200b · 20 hours ago
Use functions.openapps.xyz alias, add OpenApp contribution strip
60038fa63d · 20 hours ago
Bounded source sync
a2e0247232 · 1 day ago
Bounded source sync
c84c736f8b · 1 day ago
Bounded source sync
3a54a80cdc · 1 day ago
Bounded source sync
2eed41b4de · 1 day ago