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/services.test.mjs

View on GitHub
// @vitest-environment jsdom
import { afterEach, beforeEach, expect, it, vi } from "vitest";
import { cleanup, fireEvent, render, screen, waitFor, within } from "./test-dom.mjs";

// Sealing is the browser's own crypto, tested in seal.test.mjs: here it marks the value, so a test sees it stay.
vi.mock("./seal.mjs", () => ({ seal: async (value, publicKey) => JSON.stringify({ v: 1, wrapped: btoa(publicKey), iv: "aXY=", data: btoa(`sealed:${value.length}`) }) }));

// A shop's keys: Stripe is saved, Notion's API is saved and used directly, Mailchimp waits to be connected, and the
// Cloudflare look-up key waits for Access setup. Project code is Access's own and never a row here.
const key = (id, title, changes = {}) => ({ id, title, levels: ["read", "write"], saved: true, setup: false, alone: false, parts: ["Key"], ...changes });
const SHOP = [key("stripe", "Stripe", { purpose: "Payments and refunds" }), key("notion-api", "Notion API", { purpose: "Team notes", direct: true, docs: "https://developers.notion.com" }),
  key("mailchimp", "Mailchimp", { purpose: "Email", saved: false }), key("cloudflare", "Cloudflare", { purpose: "Account look-ups", saved: false, setup: true, parts: [] }),
  key("code", "Project code", { purpose: "This project's own code", alone: true, parts: [] })];
const status = keys => ({ ownerEmail: "owner@shop.com", viewer: { email: "owner@shop.com", owner: true }, environment: "live", key: "ready", started: true,
  imported: 0, keysStarted: true, unticked: { people: [], roles: [] }, apps: [], roles: [], people: [], work: [], project: "ready", keys });
const VALUE = "mc_live_made-up-9f2c";
let side; let keys; let fetchMock; let preview; let answer;
beforeEach(() => {
  side = "owner"; keys = SHOP; preview = false; answer = () => undefined;
  fetchMock = vi.fn(async (url, init) => {
    const special = answer(url, init);
    if (special) return special;
    if (url === "/api/access/keys/seal") return Response.json({ publicKey: "public-half" });
    if (url.startsWith("/api/access/keys/")) {
      keys = keys.map(item => (url.startsWith(`/api/access/keys/${item.id}/`) ? { ...item, waiting: { ends: "9f2c" } } : item));
      return Response.json({ name: "MAILCHIMP_KEY", ends: "9f2c", waiting: true });
    }
    if (url === "/api/access/apps") return Response.json(side === "teammate" ? { state: "current", role: "employee", apps: ["access"], revision: 1, keys: [{ id: "stripe", title: "Stripe", level: "read" }] }
      : { state: "current", role: side === "owner" ? "owner" : "employee", manages: true, apps: ["access"], revision: 1 });
    // A value the server never sends: were one sent, the screen would still not show it.
    return Response.json({ ...status(keys), ...(side === "admin" && { viewer: { email: "kim@shop.com", owner: false } }), ...(preview && { environment: "practice" }),
      keys: keys.map(item => ({ ...item, value: "sk_live_9f8e" })) });
  });
  vi.stubGlobal("fetch", fetchMock);
});
afterEach(() => { cleanup(); vi.unstubAllGlobals(); });
const open = (path = "services") => render(`/apps/access/${path}`);
const tabs = () => within(screen.getByRole("navigation", { name: "Access views" })).getAllByRole("link").map(link => link.textContent);
const line = (table, title) => Array.from(within(table).getByText(title).closest("tr").querySelectorAll("td")).map(cell => cell.textContent);
const paste = async (title, name = "Paste key") => fireEvent.click(within(within(await screen.findByRole("table", { name: "Services" })).getByText(title).closest("tr")).getByRole("button", { name }));
const sends = () => fetchMock.mock.calls.filter(([url]) => url.startsWith("/api/access/keys/"));

it("the owner and an Admin see every key: what each is for, whether it is saved, and a way to paste one, never a value or a level", async () => {
  for (const viewer of ["owner", "admin"]) {
    side = viewer; await open(); const table = await screen.findByRole("table", { name: "Services" });
    // Services is the third view, counting its keys; the project's own code is not one of them.
    expect(tabs(), viewer).toEqual(["People 1", "Roles 0", "Services 4"]); expect(screen.getByRole("link", { name: "Services 4" }).getAttribute("aria-current")).toBe("page");
    expect(within(table).getAllByRole("row").slice(1).map(row => row.querySelector("td").textContent), viewer).toEqual(["Stripe", "Notion API", "Mailchimp", "Cloudflare"]);
    expect(["Stripe", "Notion API", "Mailchimp", "Cloudflare"].map(title => line(table, title)), viewer).toEqual([["Stripe", "Payments and refunds", "Saved", "Replace key"],
      ["Notion API", "Team notes · API guide", "Savedalso used directly", "Replace key"], ["Mailchimp", "Email", "Not savedAsk the assistant to connect it, or paste the key", "Paste key"],
      ["Cloudflare", "Account look-ups", "Not savedAsk the assistant to finish Access setup", ""]]);
    // The quiet lines are muted, each on its own line; a key used directly links its API guide.
    for (const note of ["also used directly", "Ask the assistant to connect it, or paste the key"]) expect(screen.getByText(note).className).toBe("block text-muted-foreground");
    expect(within(table).getByRole("link", { name: "API guide" }).getAttribute("href")).toBe("https://developers.notion.com");
    // No value, no level, and no place to type a key until a paste box is opened.
    expect(document.body.textContent).not.toMatch(/sk_live|Read & write|Project code/);
    expect(screen.queryByRole("textbox")).toBeNull();
    cleanup();
  }
});
it("on a preview, names a key only the live app holds as such, and offers no paste box", async () => {
  preview = true; keys = SHOP.map(item => (item.id === "cloudflare" ? { ...item, liveOnly: true } : item)); await open();
  const table = await screen.findByRole("table", { name: "Services" });
  expect([line(table, "Cloudflare"), line(table, "Mailchimp"), line(table, "Stripe")]).toEqual([["Cloudflare", "Account look-ups", "Not savedLive app only", ""],
    ["Mailchimp", "Email", "Not savedAsk the assistant to connect it", "Live app only"], ["Stripe", "Payments and refunds", "Saved", "Live app only"]]);
  expect(within(table).queryByRole("button")).toBeNull();
});
it("names a tool added in a chat and what it counts as a look-up, with no value", async () => {
  keys = [key("notion", "Notion", { purpose: "Read our team wiki", direct: true, docs: "https://developers.notion.com", levels: ["read"], liveOnly: true, chat: true, reads: ["POST search"] }),
    key("figma", "Figma", { purpose: "Design files", direct: true, docs: "https://www.figma.com/developers/api", levels: ["read"], liveOnly: true, chat: true, parts: undefined })]; await open();
  const table = await screen.findByRole("table", { name: "Services" });
  expect(line(table, "Notion")).toEqual(["Notion", "Read our team wiki · API guide", "Savedalso used directlyAdded in a chat · reads: GET anything, POST search", "Replace key"]);
  // A tool with no look-ups beyond GET says so; an older status names no parts, so no paste box.
  expect(line(table, "Figma").slice(2)).toEqual(["Savedalso used directlyAdded in a chat · reads: GET anything", ""]);
  expect(document.body.textContent).not.toMatch(/sk_live/);
});
it("pastes a key: sealed on the page, sent to its place, then shown as waiting for the next publish with its last four", async () => {
  await open(); await paste("Mailchimp");
  const dialog = await screen.findByRole("alertdialog", { name: "Paste the Mailchimp key" });
  expect(within(dialog).getByText(/only the next publish can open it/)).toBeTruthy();
  // Nothing pasted: the popup says so and sends nothing.
  await fireEvent.click(within(dialog).getByRole("button", { name: "Save key" }));
  expect(within(dialog).getByRole("alert").textContent).toBe("Paste the key first.");
  const box = within(dialog).getByLabelText("Mailchimp key");
  expect([box.type, box.autocomplete]).toEqual(["password", "off"]);
  await fireEvent.change(box, { target: { value: `  ${VALUE} ` } });
  await fireEvent.click(within(dialog).getByRole("button", { name: "Save key" }));
  await waitFor(() => expect(screen.queryByRole("alertdialog")).toBeNull());
  const [[lock], [address, init]] = sends();
  expect([lock, address, init.method, init.headers.Origin]).toEqual(["/api/access/keys/seal", "/api/access/keys/mailchimp/0", "PUT", window.location.origin]);
  expect(JSON.parse(String(init.body))).toEqual({ sealed: { v: 1, wrapped: btoa("public-half"), iv: "aXY=", data: btoa(`sealed:${VALUE.length}`) }, ends: "9f2c" });
  for (const [, sent] of fetchMock.mock.calls) expect(String(sent?.body ?? "")).not.toContain("made-up");
  // The list is read again, and the row says the key waits.
  await waitFor(() => expect(line(screen.getByRole("table", { name: "Services" }), "Mailchimp")).toEqual(["Mailchimp", "Email", "Waiting for the next publish, ends in …9f2c", "Replace key"]));
  expect(document.body.textContent).not.toContain("made-up");
});
it("asks for each part of a key that has an ID and a secret, and sends each to its own place", async () => {
  keys = [key("shopify", "Shopify", { purpose: "Store orders", saved: false, chat: true, liveOnly: true, parts: ["Secret", "ID"] })]; await open();
  await paste("Shopify");
  const dialog = await screen.findByRole("alertdialog", { name: "Paste the Shopify key" });
  await fireEvent.change(within(dialog).getByLabelText("Secret"), { target: { value: "shpss_made-up-1234" } });
  await fireEvent.click(within(dialog).getByRole("button", { name: "Save key" }));
  expect(within(dialog).getByRole("alert").textContent).toBe("Paste the key first.");
  await fireEvent.change(within(dialog).getByLabelText("ID"), { target: { value: "client-made-up-5678" } });
  await fireEvent.click(within(dialog).getByRole("button", { name: "Save key" }));
  await waitFor(() => expect(screen.queryByRole("alertdialog")).toBeNull());
  expect(sends().slice(1).map(([address, init]) => [address, JSON.parse(String(init.body)).ends])).toEqual([["/api/access/keys/shopify/0", "1234"], ["/api/access/keys/shopify/1", "5678"]]);
});
it("keeps a refusal in the popup, in words, and Cancel clears what was pasted", async () => {
  await open(); await paste("Mailchimp");
  let dialog = await screen.findByRole("alertdialog");
  const type = () => fireEvent.change(within(dialog).getByLabelText("Mailchimp key"), { target: { value: VALUE } });
  const refusals = [
    [url => (url.endsWith("/seal") ? Response.json({ error: { code: "no_seal" } }, { status: 409 }) : undefined), "This app has no lock for keys yet. Ask the assistant to make the pair of locks."],
    [url => (url.endsWith("/0") ? Response.json({ error: { code: "live_only" } }, { status: 409 }) : undefined), "Only the live app takes a key."],
    [url => (url.endsWith("/0") ? new Response("Bad gateway", { status: 502 }) : undefined), "The key was not sent. Try again."]];
  for (const [refuse, words] of refusals) {
    answer = refuse; await type();
    await fireEvent.click(within(dialog).getByRole("button", { name: "Save key" }));
    await waitFor(() => expect(within(dialog).getByRole("alert").textContent).toBe(words));
    expect(screen.getByRole("alertdialog")).toBe(dialog);
  }
  await fireEvent.click(within(dialog).getByRole("button", { name: "Cancel" }));
  await waitFor(() => expect(screen.queryByRole("alertdialog")).toBeNull());
  await paste("Mailchimp"); dialog = await screen.findByRole("alertdialog");
  expect([within(dialog).getByLabelText("Mailchimp key").value, within(dialog).queryByRole("alert")]).toEqual(["", null]);
  // A saved key's box replaces it.
  await fireEvent.click(within(dialog).getByRole("button", { name: "Cancel" }));
  await paste("Stripe", "Replace key");
  expect(await screen.findByRole("alertdialog", { name: "Replace the Stripe key" })).toBeTruthy();
});
it("with no keys yet, says to ask the assistant to connect a service", async () => {
  keys = [key("code", "Project code", { alone: true })]; await open();
  await screen.findByText("No keys yet. Ask the assistant to connect a service.");
  expect([tabs(), screen.queryByRole("table")]).toEqual([["People 1", "Roles 0", "Services 0"], null]);
});
it("a teammate gets no Services view, and its address shows only what they can use", async () => {
  side = "teammate"; await open(); await screen.findByRole("region", { name: "You can use" });
  expect([screen.queryByRole("navigation"), screen.queryByRole("link", { name: /Services/ }), screen.queryByRole("table")]).toEqual([null, null, null]);
  // Their own key shows with their level, and nothing about the other keys.
  expect(document.body.textContent).not.toMatch(/Mailchimp|Notion|Saved|Paste key/);
  expect(fetchMock.mock.calls.map(([url]) => url)).not.toContain("/api/access/status");
});
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