Skip to content

matthewwong525/WongStack / .agents/plugins/access

access

Verified

See who can sign in and what each person may use; add, change or remove a person.

FileKindSize
README.mdmarkdown3.4 KB
SKILL.mdskill md2.3 KB
VERSIONother6 B
hooks/claude.jsonconfig251 B
hooks/codex.jsonconfig232 B
references/setup.mdmarkdown9.7 KB
screen/access.cssother10.5 KB
screen/address.mjsscript2.1 KB
screen/api.mjsscript11.6 KB
screen/api.test.mjsscript13.4 KB
screen/app.mjsscript1.2 KB
screen/app.test.mjsscript40.3 KB
screen/confirm.mjsscript1.1 KB
screen/context.mjsscript248 B
screen/copy-text.mjsscript1.3 KB
screen/fields.mjsscript1001 B
screen/hidden.test.mjsscript6.8 KB
screen/labels.mjsscript1.4 KB
screen/leaving.test.mjsscript14.6 KB
screen/level-choice.mjsscript1.3 KB
screen/levels.mjsscript3.7 KB
screen/levels.test.mjsscript7.9 KB
screen/loading.mjsscript457 B
screen/main.d.mtsother1.0 KB
screen/main.mjsscript1.3 KB
screen/note.mjsscript2.1 KB
screen/note.test.mjsscript4.1 KB
screen/notices.mjsscript4.3 KB
screen/notices.test.mjsscript2.2 KB
screen/own.mjsscript889 B
screen/owner.mjsscript2.7 KB
screen/page.mjsscript4.2 KB
screen/people.mjsscript4.5 KB
screen/person-page.mjsscript3.5 KB
screen/person-page.test.mjsscript37.2 KB
screen/project-step.mjsscript1.7 KB
screen/project-step.test.mjsscript5.4 KB
screen/pushers.mjsscript3.5 KB
screen/pushers.test.mjsscript5.2 KB
screen/role-page.mjsscript2.5 KB
screen/role-select.mjsscript1.6 KB
screen/roles.mjsscript1.5 KB
screen/roles.test.mjsscript22.2 KB
screen/router.mjsscript3.3 KB
screen/seal.d.mtsother470 B
screen/seal.mjsscript2.6 KB
screen/seal.test.mjsscript1.1 KB
screen/services.mjsscript4.3 KB
screen/services.test.mjsscript12.5 KB
screen/set-fields.mjsscript3.5 KB
screen/status.mjsscript2.4 KB
screen/status.test.mjsscript2.7 KB
screen/style.test.mjsscript11.5 KB
screen/subjects.mjsscript487 B
screen/subjects.test.mjsscript2.4 KB
screen/table.mjsscript4.5 KB
screen/test-dom.mjsscript9.4 KB
screen/ui.mjsscript14.2 KB
screen/view.mjsscript2.1 KB
screen/welcome.mjsscript2.3 KB
screen/welcome.test.mjsscript11.2 KB
scripts/check-definitions.mjsexecutablescript1.1 KB
scripts/lib/check-definitions.mjsscript1.2 KB
scripts/lib/client.mjsscript4.6 KB
scripts/lib/openapi.mjsscript20.6 KB
scripts/lib/scrub.mjsscript7.0 KB
scripts/lib/seal-keys.mjsscript1.1 KB
scripts/lib/services.mjsscript17.6 KB
scripts/services.mjsexecutablescript8.6 KB
scripts/session-start.mjsscript1.7 KB
server/errors.d.mtsother572 B
server/errors.mjsscript1.8 KB
server/errors.test.mjsscript1.3 KB
server/forward.d.mtsother1.6 KB
server/forward.mjsscript11.0 KB
server/forward.test.mjsscript9.4 KB
server/index.d.mtsother3.3 KB
server/index.mjsscript11.3 KB
server/index.test.mjsscript11.8 KB
server/key-rules.d.mtsother643 B
server/key-rules.mjsscript4.0 KB
server/key-rules.test.mjsscript5.2 KB
server/levels.d.mtsother2.3 KB
server/levels.mjsscript4.3 KB
server/levels.test.mjsscript2.4 KB
server/management.mjsscript2.8 KB
server/page.mjsscript1.3 KB
server/pass.d.mtsother213 B
server/pass.mjsscript3.5 KB
server/people.mjsscript5.3 KB
server/policy.d.mtsother1.5 KB
server/policy.mjsscript8.1 KB
server/roles.mjsscript2.4 KB
server/sealed.d.mtsother377 B
server/sealed.mjsscript3.2 KB
server/sealed.test.mjsscript4.9 KB
server/services.d.mtsother487 B
server/services.mjsscript3.1 KB
server/services.test.mjsscript4.5 KB
server/sets.mjsscript4.5 KB
server/start.mjsscript1.8 KB
server/tools.d.mtsother1.2 KB
server/tools.mjsscript8.7 KB
server/tools.test.mjsscript10.4 KB
signin/cloudflare-list.d.mtsother969 B
signin/cloudflare-list.mjsscript11.6 KB
signin/cloudflare-list.test.mjsscript1.4 KB
signin/cloudflare.d.mtsother1.5 KB
signin/cloudflare.mjsscript7.2 KB
signin/cloudflare.test.mjsscript1.4 KB
signin/computer.d.mtsother557 B
signin/computer.mjsscript2.4 KB
signin/computer.test.mjsscript1.0 KB
store/contract.d.mtsother293 B
store/contract.mjsscript14.3 KB
store/interface.d.mtsother4.2 KB
store/interface.mjsscript1.2 KB
store/stand-in.d.mtsother93 B
store/stand-in.mjsscript10.4 KB
store/stand-in.test.mjsscript202 B

screen/api.mjs

View on GitHub
// The page's client for the Access API: each read checked by hand before a screen sees it, and each change sent with
// the page's origin. No key's value is ever read; the server checks who is asking again on every change.
import { useEffect, useMemo, useState } from "./vendor/preact-htm.mjs";
import { seal } from "./seal.mjs";

const wrong = what => { throw new Error(`Access answer not readable: ${what}`); };
const isObject = value => typeof value === "object" && value !== null && !Array.isArray(value);
const object = (value, what) => (isObject(value) ? value : wrong(what));
const text = (value, what) => (typeof value === "string" ? value : wrong(what));
const flag = (value, what) => (typeof value === "boolean" ? value : wrong(what));
const maybe = (value, check, what) => (value === undefined ? undefined : check(value, what));
const list = (value, what, each = text) => (Array.isArray(value) ? value.map((item, at) => each(item, `${what}[${at}]`)) : wrong(what));
const oneOf = (words, value, what) => (words.includes(value) ? value : wrong(what));
const LEVELS = ["read", "write"];
const level = (value, what) => oneOf(LEVELS, value, what);
const levels = (value, what) => Object.fromEntries(Object.entries(object(value, what)).map(([id, held]) => [id, level(held, `${what}.${id}`)]));
const PROJECT = ["ready", "key", "setup", "live"];
const project = (value, what) => oneOf(PROJECT, value, what);

/** Who may connect an assistant: `ready` installs the project, `lacked` greys Connect, `off` or none: apps only. */
const code = value => (value === undefined ? "off" : oneOf(["ready", "lacked", "off"], value, "code"));
const signIn = value => maybe(value, flag, "signIn");

/** The apps answer: `legacy` has no recorded owner, `not_started` keeps every app, `current` lists the person's apps
 *  and their own level per saved key. `manages`: the owner or an Admin. */
export function readApps(raw) {
  const answer = object(raw, "apps");
  const state = oneOf(["legacy", "not_started", "current"], answer.state, "state");
  if (state === "legacy") return { state, signIn: signIn(answer.signIn), code: code(answer.code) };
  const role = oneOf(["owner", "employee"], answer.role, "role");
  const base = { state, role, manages: maybe(answer.manages, flag, "manages"), signIn: signIn(answer.signIn), code: code(answer.code), apps: list(answer.apps, "apps") };
  if (state === "not_started") return base;
  if (!Number.isFinite(answer.revision)) wrong("revision");
  const keys = maybe(answer.keys, (value, what) => list(value, what, (key, at) => {
    const item = object(key, at);
    return { id: text(item.id, `${at}.id`), title: text(item.title, `${at}.title`), level: level(item.level, `${at}.level`) };
  }), "keys");
  return { ...base, revision: answer.revision, keys };
}

/** The viewer's own setup message, read only to fold it into a welcome note. */
export function readSetup(raw) {
  const answer = object(raw, "setup");
  const prompt = object(answer.prompt, "prompt");
  if (prompt.state === "ready") return { prompt: { state: "ready", text: text(prompt.text, "prompt.text") } };
  return { prompt: { state: oneOf(["unavailable"], prompt.state, "prompt.state") } };
}

const app = (value, what) => {
  const item = object(value, what);
  return { id: text(item.id, `${what}.id`), title: text(item.title, `${what}.title`), description: text(item.description ?? "", `${what}.description`) };
};
const key = (value, what) => {
  const item = object(value, what);
  const yes = name => maybe(item[name], flag, `${what}.${name}`);
  const word = name => maybe(item[name], text, `${what}.${name}`);
  return { id: text(item.id, `${what}.id`), title: text(item.title, `${what}.title`), levels: list(item.levels, `${what}.levels`, level),
    saved: flag(item.saved, `${what}.saved`), setup: flag(item.setup ?? false, `${what}.setup`), alone: flag(item.alone ?? false, `${what}.alone`),
    liveOnly: yes("liveOnly"), direct: yes("direct"), purpose: word("purpose"), docs: word("docs"), chat: yes("chat"),
    reads: maybe(item.reads, list, `${what}.reads`), parts: maybe(item.parts, list, `${what}.parts`),
    waiting: maybe(item.waiting, (waiting, at) => ({ ends: text(object(waiting, at).ends, `${at}.ends`) }), `${what}.waiting`) };
};
// A role's or a person's set: apps and key levels, empty when the project gives no apps or keys.
const set = (item, what) => ({ apps: maybe(item.apps, list, `${what}.apps`) ?? [], keys: maybe(item.keys, levels, `${what}.keys`) ?? {} });
const role = (value, what) => {
  const item = object(value, what);
  return { id: text(item.id, `${what}.id`), name: text(item.name, `${what}.name`), builtIn: maybe(item.builtIn, flag, `${what}.builtIn`), ...set(item, what) };
};
const person = (value, what) => {
  const item = object(value, what);
  return { email: text(item.email, `${what}.email`), status: oneOf(["active", "removed"], item.status, `${what}.status`),
    settled: flag(item.settled, `${what}.settled`), role: item.role === null ? null : text(item.role, `${what}.role`), ...set(item, what) };
};
const named = field => (value, what) => {
  const item = object(value, what);
  return { [field]: text(item[field], `${what}.${field}`), apps: list(item.apps, `${what}.apps`) };
};
const work = (value, what) => {
  const item = object(value, what);
  return { kind: oneOf(["policy", "sessions"], item.kind, `${what}.kind`), status: oneOf(["pending", "ready", "failed"], item.status, `${what}.status`) };
};

/** The whole Access status. A part the project has no slot for is left out, and its section hides: no `apps`, no
 *  ticks; no `keys`, no levels; no `key` or `key: 'none'`, no sign-in state; no `project`, no Project code step. */
export function readStatus(raw) {
  const status = object(raw, "status");
  const viewer = object(status.viewer, "viewer");
  const apps = maybe(status.apps, (value, what) => list(value, what, app), "apps");
  const unticked = status.unticked === undefined && !apps ? { people: [], roles: [] } : object(status.unticked, "unticked");
  if (!Number.isFinite(status.imported ?? 0)) wrong("imported");
  return {
    ownerEmail: text(status.ownerEmail, "ownerEmail"), environment: oneOf(["live", "practice"], status.environment, "environment"),
    viewer: { email: text(viewer.email, "viewer.email"), owner: flag(viewer.owner, "viewer.owner") },
    // `none`, like no `key` at all: the project keeps no sign-in list, so no row has a sign-in state.
    key: status.key === "none" ? undefined : maybe(status.key, (value, what) => oneOf(["ready", "missing", "practice"], value, what), "key"),
    started: flag(status.started ?? true, "started"), imported: status.imported ?? 0,
    startError: status.startError === null ? null : maybe(status.startError, text, "startError"),
    keysStarted: flag(status.keysStarted ?? true, "keysStarted"),
    apps, keys: maybe(status.keys, (value, what) => list(value, what, key), "keys"),
    unticked: { people: list(unticked.people, "unticked.people", named("email")), roles: list(unticked.roles, "unticked.roles", named("name")) },
    roles: list(status.roles, "roles", role), people: list(status.people, "people", person), work: list(status.work ?? [], "work", work),
    project: maybe(status.project, project, "project"), projectSave: maybe(status.projectSave, project, "projectSave"),
  };
}

/** Who can push to the project on GitHub, each let in to previews alone, and why none are listed. */
export function readPushers(raw) {
  const answer = object(raw, "pushers");
  return { state: oneOf(["listed", "unavailable", "no_github", "not_github", "not_started", "live_only"], answer.state, "state"),
    split: maybe(answer.split, flag, "split"),
    pushers: list(answer.pushers, "pushers", (value, what) => {
      const item = object(value, what);
      if (!Number.isFinite(item.githubId)) wrong(`${what}.githubId`);
      return { githubId: item.githubId, login: text(item.login, `${what}.login`), email: item.email === null ? null : text(item.email, `${what}.email`),
        emailSource: item.emailSource === null ? null : oneOf(["owner", "profile", "commit"], item.emailSource, `${what}.emailSource`),
        canOpenPreviews: flag(item.canOpenPreviews, `${what}.canOpenPreviews`) };
    }) };
}

/** Whether a person holds the built-in Admin role. */
export const isAdmin = (status, person) => status.roles.some(item => item.builtIn && item.id === person.role);

/** Why a pasted key was not sent, in words for the person. */
const KEY_REFUSALS = new Map([
  ["no_seal", "This app has no lock for keys yet. Ask the assistant to make the pair of locks."],
  ["live_only", "Only the live app takes a key."],
  ["bad_name", "This key can not be pasted here."],
]);

/** The client for one API base, such as `/api/access/`: reads, changes, a pusher's email, and a key sent sealed. */
export function client(base = "/api/access/") {
  const root = base.endsWith("/") ? base : `${base}/`;
  const send = (path, method, body) => fetch(`${root}${path}`, { method, redirect: "error",
    headers: { Origin: window.location.origin, "Content-Type": "application/json" }, body: JSON.stringify(body ?? {}) });
  const refused = async response => {
    const answer = await response.json().catch(() => null);
    const said = isObject(answer) && isObject(answer.error) ? answer.error.code : undefined;
    return new Error(KEY_REFUSALS.get(String(said)) ?? "The key was not sent. Try again.");
  };
  return {
    async read(path, check, signal) {
      const response = await fetch(`${root}${path}`, { signal, cache: "no-store", redirect: "error" });
      if (!response.ok) throw new Error("Access unavailable");
      return check(await response.json());
    },
    async change(path, body) {
      const response = await send(path, "POST", body);
      if (!response.ok) throw new Error("Access change unavailable");
    },
    /** The owner or an Admin types a pusher's email; the server checks again who is asking. */
    async savePusherEmail(githubId, email) {
      const response = await send(`pushers/${githubId}`, "PUT", { email });
      if (!response.ok) throw new Error("Access change unavailable");
    },
    /** Seals each part of a key on this page with the publish's public key, then sends it to the key's place in the
     *  app: the value never leaves the page unsealed. Throws the words to show when the app refuses. */
    async sendKey(id, values) {
      const lock = await fetch(`${root}keys/seal`, { cache: "no-store", redirect: "error" });
      if (!lock.ok) throw await refused(lock);
      const publicKey = text(object(await lock.json(), "seal").publicKey, "publicKey");
      for (const [part, value] of values.entries()) {
        const sealed = JSON.parse(await seal(value, publicKey));
        const response = await send(`keys/${encodeURIComponent(id)}/${part}`, "PUT", { sealed, ends: value.slice(-4) });
        if (!response.ok) throw await refused(response);
      }
    },
  };
}

/** One read kept current: a new path, check or reload hides the previous answer at once, and only this exact request's
 *  answer shows. `api` is the page's client. */
export function useAccess(api, path, check) {
  const [revision, refresh] = useState(0);
  const key = useMemo(() => ({ path, check, revision }), [path, check, revision]);
  const [state, setState] = useState({ key: null, data: null, error: false });
  useEffect(() => {
    const controller = new AbortController();
    api.read(key.path, key.check, controller.signal).then(
      data => { if (!controller.signal.aborted) setState({ key, data, error: false }); },
      () => { if (!controller.signal.aborted) setState({ key, data: null, error: true }); },
    );
    return () => controller.abort();
  }, [key]);
  const current = state.key === key;
  return { data: current ? state.data : null, error: current && state.error, reload: () => refresh(value => value + 1) };
}
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall