lists-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 ebccaf0b13fe
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 ee59501e91bae6d2c23a8370
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/bounded.ts
// One Bounded session per browser: a guest account, created on first use. No sign-up, ever.
import { init, getCurrentUser, signInAnonymously } from "@bounded-sh/client";
import { APP_ID } from "../../functions/lib/config";
import { read, write } from "./local";

/** The app this page is served for: the host injects it, so a preview talks to its own data. Local dev falls back to config. */
export const SERVED_APP_ID =
  (typeof document !== "undefined" && document.getElementById("__bounded-first-live-bridge")?.getAttribute("data-app-id")) || APP_ID;

let session: Promise<string> | null = null;

/** Resolves to this browser's guest user id, signing in once. Remembers the id so lists can be made offline later. */
export function me(): Promise<string> {
  session ??= (async () => {
    await init({ appId: SERVED_APP_ID });
    const user = getCurrentUser() || (await signInAnonymously());
    if (!user?.id) throw new Error("Could not start a guest session.");
    write("lists:uid", user.id as string);
    return user.id as string;
  })().catch((err) => {
    session = null;
    throw err;
  });
  return session;
}

/** The guest id, waiting at most `ms` for the network; falls back to the id this browser had before. */
export async function meSoon(ms = 8000): Promise<string | null> {
  try {
    return await Promise.race([me(), new Promise<never>((_, no) => setTimeout(() => no(new Error("timeout")), ms))]);
  } catch {
    return read<string | null>("lists:uid", null);
  }
}

/** A sentence a person can read for a failed write or read. */
export function explain(err: unknown): string {
  const e = err as { message?: string; decline?: { message?: string } };
  if (e?.decline?.message) return e.decline.message;
  const msg = String(e?.message || err || "");
  if (/network|fetch|timeout|offline/i.test(msg) || (typeof navigator !== "undefined" && !navigator.onLine)) return "You seem to be offline. Try again when you have a connection.";
  if (/denied|403|forbidden|violate/i.test(msg)) return "That change was not allowed.";
  return msg || "Something went wrong. Try again.";
}

Change history

Point OpenApps links to openapps.free
ebccaf0b13 · 17 hours ago
Bind agent address in policy constants
519855687c · 19 hours ago
Use OpenApps service URLs and add contribution strip
2c353edfdc · 19 hours ago
Bounded source sync
58ac7e08ec · 1 day ago
Bounded source sync
150962f3d9 · 1 day ago
Bounded source sync
e52e4676b9 · 1 day ago