@aarwitz/tapp 0.28.0 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tapp",
3
3
  "description": "Give Claude hands and eyes on iOS, Android, and web apps, with exploration, replayable flows, evidence, and deterministic CI gates.",
4
- "version": "0.28.0",
4
+ "version": "0.29.0",
5
5
  "author": {
6
6
  "name": "Aaron Horowitz",
7
7
  "url": "https://github.com/aarwitz"
@@ -24,7 +24,7 @@
24
24
  "command": "npx",
25
25
  "args": [
26
26
  "-y",
27
- "@aarwitz/tapp@0.28.0",
27
+ "@aarwitz/tapp@0.29.0",
28
28
  "mcp"
29
29
  ],
30
30
  "cwd": "${CLAUDE_PROJECT_DIR}"
package/browser/app.css CHANGED
@@ -594,3 +594,13 @@ dialog::backdrop { background:rgba(0,0,0,.6); }
594
594
  .token-reveal button { font:inherit; font-size:12px; padding:7px 12px; border-radius:8px; cursor:pointer; }
595
595
  .owned-link { text-align:center; margin-top:10px; }
596
596
  .owned-link button { font:inherit; font-size:13px; padding:7px 14px; border-radius:999px; border:1px solid var(--line); background:var(--control); color:inherit; cursor:pointer; }
597
+ .read-only-note { margin:6px 0 14px; font-size:12.5px; line-height:1.5; }
598
+
599
+ /* Sign in on our own page: a provider button, or an emailed link. */
600
+ .signin-lead { margin:0 0 12px; }
601
+ #signin-providers { display:grid; gap:8px; }
602
+ .signin-provider { display:flex; align-items:center; justify-content:center; gap:10px; padding:11px 14px; border-radius:10px; border:1px solid var(--line); background:var(--control); color:inherit; text-decoration:none; font-size:14px; font-weight:600; }
603
+ .signin-provider:hover { border-color:var(--tapp-accent, #4f6cf7); }
604
+ .signin-provider.google { background:#fff; color:#1f2328; border-color:#dadce0; }
605
+ .signin-or { display:flex; align-items:center; gap:10px; color:var(--muted); font-size:12px; margin:4px 0 2px; }
606
+ .signin-or::before, .signin-or::after { content:""; flex:1; height:1px; background:var(--line); }
package/browser/app.js CHANGED
@@ -105,6 +105,23 @@ function renderAccount() {
105
105
  : `<button type="button" class="primary" data-signin>Sign in</button>`;
106
106
  }
107
107
  $("#signin-card")?.classList.toggle("hidden", session.access !== "anonymous" || !state.signInOpen);
108
+ renderSignInOptions();
109
+ }
110
+
111
+ // The ways in this deployment actually offers. A button with nothing configured behind it is
112
+ // never shown, so the card can never promise a sign-in that cannot happen.
113
+ function renderSignInOptions() {
114
+ const slot = $("#signin-providers");
115
+ if (!slot) return;
116
+ const providers = (state.session?.signInOptions || []).filter((option) => option.kind !== "email");
117
+ slot.innerHTML = providers.map((option) => `<a class="signin-provider ${esc(option.kind)}" href="/auth/${esc(option.kind)}">${providerMark(option.kind)}<span>${esc(option.label)}</span></a>`).join("")
118
+ + (providers.length ? '<div class="signin-or"><span>or</span></div>' : "");
119
+ }
120
+
121
+ function providerMark(kind) {
122
+ if (kind === "google") return '<svg viewBox="0 0 18 18" width="16" height="16" aria-hidden="true"><path fill="#4285F4" d="M17.6 9.2c0-.6-.1-1.2-.2-1.8H9v3.4h4.8a4.1 4.1 0 0 1-1.8 2.7v2.2h2.9c1.7-1.6 2.7-3.9 2.7-6.5z"/><path fill="#34A853" d="M9 18c2.4 0 4.5-.8 6-2.2l-2.9-2.2a5.4 5.4 0 0 1-8.1-2.8H1v2.3A9 9 0 0 0 9 18z"/><path fill="#FBBC05" d="M3.9 10.7a5.4 5.4 0 0 1 0-3.4V5H1a9 9 0 0 0 0 8l2.9-2.3z"/><path fill="#EA4335" d="M9 3.6c1.3 0 2.5.5 3.4 1.3L15 2.3A9 9 0 0 0 1 5l2.9 2.3A5.4 5.4 0 0 1 9 3.6z"/></svg>';
123
+ if (kind === "github") return '<svg viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M8 0a8 8 0 0 0-2.5 15.6c.4.1.5-.2.5-.4v-1.4C3.8 14.2 3.3 13 3.3 13c-.4-1-.9-1.2-.9-1.2-.8-.5 0-.5 0-.5.8.1 1.3.9 1.3.9.7 1.2 1.9.9 2.4.7 0-.6.3-.9.5-1.1-1.8-.2-3.6-.9-3.6-3.9 0-.9.3-1.6.8-2.1-.1-.2-.4-1 .1-2.1 0 0 .7-.2 2.2.8a7.6 7.6 0 0 1 4 0c1.5-1 2.2-.8 2.2-.8.5 1.1.2 1.9.1 2.1.5.5.8 1.2.8 2.1 0 3-1.8 3.7-3.6 3.9.3.3.5.8.5 1.5v2.2c0 .2.1.5.6.4A8 8 0 0 0 8 0z"/></svg>';
124
+ return "";
108
125
  }
109
126
 
110
127
  async function requestSignInLink(email) {
@@ -551,7 +568,8 @@ function renderRunDetail(run) {
551
568
  const audit = run.audit;
552
569
  const counts = audit.findingCounts || {};
553
570
  const issues = audit.issues || [];
554
- $("#run-detail").innerHTML = `<div class="run-detail-head"><div><p class="eyebrow">READ-ONLY AUDIT</p><h2>${esc(audit.url)}</h2><small><code>${esc(audit.id)}</code> · ${compactDate(audit.createdAt)} · nothing was clicked</small></div>${evidenceLink(audit.id, "Visual report")}</div><div class="run-stats"><div><strong>${audit.pagesAudited || 0}</strong><small>pages</small></div><div><strong>${issues.length}</strong><small>distinct issues</small></div><div><strong>${counts.high || 0}</strong><small>high</small></div><div><strong>${counts.medium || 0}</strong><small>medium</small></div></div><h3>Issues</h3>${issues.length ? `<ul class="detail-list">${issues.slice(0, 40).map((issue) => `<li><b>${esc(issue.severity)}</b> · ${esc(issue.title)}${issue.pages?.length > 1 ? ` <small>(${issue.pages.length} pages)</small>` : ""}</li>`).join("")}</ul>` : '<p class="muted">Nothing broken was observed. This says the pages are served without structural defects, not that the site works.</p>'}${renderObservations(audit)}${detailLists(audit)}`;
571
+ $("#run-detail").innerHTML = `<div class="run-detail-head"><div><p class="eyebrow">READ-ONLY AUDIT</p><h2>${esc(audit.url)}</h2><small><code>${esc(audit.id)}</code> · ${compactDate(audit.createdAt)} · nothing was clicked</small></div>${evidenceLink(audit.id, "Visual report")}</div>
572
+ <p class="muted read-only-note">This pass only <b>looks</b>: it never presses, types or submits, so a pop-up stays where it is and anything behind a click was not seen.${state.session?.access === "anonymous" ? " Sign in and tapp goes inside instead — it gets past pop-ups, clicks the controls, and asks you for a test account when it meets a sign-in." : " Put a URL in the prompt and tapp goes inside instead."}</p><div class="run-stats"><div><strong>${audit.pagesAudited || 0}</strong><small>pages</small></div><div><strong>${issues.length}</strong><small>distinct issues</small></div><div><strong>${counts.high || 0}</strong><small>high</small></div><div><strong>${counts.medium || 0}</strong><small>medium</small></div></div><h3>Issues</h3>${issues.length ? `<ul class="detail-list">${issues.slice(0, 40).map((issue) => `<li><b>${esc(issue.severity)}</b> · ${esc(issue.title)}${issue.pages?.length > 1 ? ` <small>(${issue.pages.length} pages)</small>` : ""}</li>`).join("")}</ul>` : '<p class="muted">Nothing broken was observed. This says the pages are served without structural defects, not that the site works.</p>'}${renderObservations(audit)}${detailLists(audit)}`;
555
573
  return;
556
574
  }
557
575
  if (run.kind === "explore") {
@@ -1043,6 +1061,7 @@ function signInOutcome() {
1043
1061
  try { window.history.replaceState({}, "", window.location.pathname); } catch { /* history may be unavailable */ }
1044
1062
  if (outcome === "done") toast(`Signed in${state.session?.email ? ` as ${state.session.email}` : ""}.`);
1045
1063
  if (outcome === "expired") { toast("That sign-in link has expired or was already used — ask for a new one.", true); state.signInOpen = true; renderAccount(); }
1064
+ if (outcome === "failed") { toast("That sign-in did not complete. Try again, or ask for a link by email.", true); state.signInOpen = true; renderAccount(); }
1046
1065
  }
1047
1066
 
1048
1067
  function handoffTarget() {
@@ -65,8 +65,9 @@
65
65
  <!-- Signing in to a public Studio: an email address and a link, nothing else. Hidden on a
66
66
  local Studio, where the one person at the keyboard is the operator already. -->
67
67
  <section class="signin-card hidden" id="signin-card" aria-live="polite">
68
+ <p class="signin-lead"><strong>Sign in to go inside a site.</strong> tapp can stop at a sign-in and ask you for a test account, then remember it — for that it needs to know it is you.</p>
69
+ <div id="signin-providers"></div>
68
70
  <form id="signin-form" autocomplete="email">
69
- <p><strong>Sign in to go inside a site.</strong> tapp can stop at a sign-in and ask you for a test account, then remember it — for that it needs to know it is you.</p>
70
71
  <div class="signin-row"><input id="signin-email" name="email" type="email" placeholder="you@company.com" required><button class="primary" type="submit" id="signin-send">Email me a link</button></div>
71
72
  <small>No password. The link works once and expires in 15 minutes.</small>
72
73
  </form>
@@ -93,6 +93,23 @@ There is no password. Links work once and expire in 15 minutes; sessions last 90
93
93
  SHA-256 of either token is on disk (`account-store.js`). One address may ask for five links per
94
94
  ten minutes, and the reply is the same whether or not the address has an account.
95
95
 
96
+ **Signing in with Google or GitHub (preferred).** Set a client id and secret and the sign-in card
97
+ grows a button; set neither and it does not, so the card never offers a way in that cannot work:
98
+
99
+ ```
100
+ TAPP_OAUTH_GOOGLE_CLIENT_ID=… TAPP_OAUTH_GOOGLE_CLIENT_SECRET=…
101
+ TAPP_OAUTH_GITHUB_CLIENT_ID=… TAPP_OAUTH_GITHUB_CLIENT_SECRET=…
102
+ ```
103
+
104
+ Register the redirect URI as `<origin>/auth/<provider>/callback`. The flow is a plain
105
+ authorization code exchange (`oauth.js`): `/auth/google` sends the person to the provider with a
106
+ one-time `state` kept in an `HttpOnly` cookie scoped to `/auth`, and `/auth/google/callback`
107
+ refuses anything whose state does not match the cookie it was started with — so a callback URL
108
+ sent to somebody else signs nobody in. The scope is `openid email` (or `user:email`), the address
109
+ must be **verified** by the provider, and the access token is used once and never stored: a tapp
110
+ account is an email address and nothing else. The page is ours; only the provider's own consent
111
+ screen is theirs.
112
+
96
113
  **Cloudflare Access instead of mail.** When the host is fronted by Cloudflare, put an Access
97
114
  application on exactly `app.runtapp.com/auth/cloudflare` (policy: allow everyone; login method:
98
115
  one-time PIN or Google) and set `TAPP_ACCESS_TEAM_DOMAIN` (`<team>.cloudflareaccess.com`) and
@@ -21,6 +21,7 @@ import { AccountStore } from "./account-store.js";
21
21
  import { ActorStore, hostKey } from "./actor-store.js";
22
22
  import { createMailer, signInMessage } from "./mailer.js";
23
23
  import { accessConfig, createAccessVerifier } from "./access-jwt.js";
24
+ import { oauthProviders, oauthAuthorizeUrl, oauthEmailFromCode, isOauthProvider } from "./oauth.js";
24
25
  import { journeyFromCapture, JourneyStore, slugify } from "./journeys.js";
25
26
 
26
27
  const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
@@ -124,6 +125,8 @@ const VISITOR_COOKIE = "tapp_visitor";
124
125
  // A signed-in tapp account on a public Studio (ADR-0009 slice 2). The cookie is a session token
125
126
  // whose hash the account store knows; see account-store.js.
126
127
  const ACCOUNT_COOKIE = "tapp_account";
128
+ // One-time value tying an OAuth callback to the browser that started it.
129
+ const OAUTH_STATE_COOKIE = "tapp_oauth_state";
127
130
 
128
131
  // What a signed-out visitor on a public Studio may reach. Everything absent from this list is
129
132
  // refused, so a new route is private until someone deliberately opens it.
@@ -134,8 +137,9 @@ function anonymousAllows(method, pathname) {
134
137
  if (/^\/api\/captures\/[A-Za-z0-9._-]{1,128}\/files$/.test(pathname)) return true;
135
138
  if (/^\/evidence\/captures\//.test(pathname)) return true;
136
139
  if (/^\/api\/jobs\/[a-f0-9]{20}(\/frame)?$/.test(pathname)) return true;
137
- // Following a sign-in link from an email, or arriving back from Cloudflare Access.
138
- if (pathname === "/auth/cloudflare" || /^\/auth\/[A-Za-z0-9_-]{20,}$/.test(pathname)) return true;
140
+ // Following a sign-in link from an email, arriving back from Cloudflare Access, or either
141
+ // leg of "Continue with Google".
142
+ if (pathname === "/auth/cloudflare" || /^\/auth\/[a-z]{2,20}(\/callback)?$/.test(pathname) || /^\/auth\/[A-Za-z0-9_-]{20,}$/.test(pathname)) return true;
139
143
  return false;
140
144
  }
141
145
  // Asking for a sign-in link is the one thing a stranger may post besides a run.
@@ -536,7 +540,7 @@ function serveLoginPage(response, { failed = false, next = "" } = {}) {
536
540
  response.end(html);
537
541
  }
538
542
 
539
- export async function startBrowserProduct({ projectDir, port = 0, launch = false, workspaceRoot, githubProvider, publicOrigin = "", trustedProxyToken = "", directLogin = null, publicEgressOnly = null, publicAccess = false, accessVerifier = undefined } = {}) {
543
+ export async function startBrowserProduct({ projectDir, port = 0, launch = false, workspaceRoot, githubProvider, publicOrigin = "", trustedProxyToken = "", directLogin = null, publicEgressOnly = null, publicAccess = false, accessVerifier = undefined, oauthExchange = null } = {}) {
540
544
  const hosted = !!trustedProxyToken || !!directLogin || !!publicAccess;
541
545
  // publicOrigin accepts a comma-separated allowlist; the first entry is canonical.
542
546
  const publicOrigins = String(publicOrigin || "").split(",").map((value) => value.trim().replace(/\/$/, "")).filter(Boolean);
@@ -576,7 +580,11 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
576
580
  // assertion and tapp sends no email at all. Configured by TAPP_ACCESS_TEAM_DOMAIN + TAPP_ACCESS_AUD;
577
581
  // tests inject a verifier. The email link stays available as the provider-free path.
578
582
  const access = accessVerifier !== undefined ? accessVerifier : (publicAccess && accessConfig() ? createAccessVerifier(accessConfig()) : null);
579
- const signInProvider = access ? "cloudflare" : "email";
583
+ // What this deployment can actually offer, in the order the sign-in card shows them. A button
584
+ // with no client id behind it is never rendered.
585
+ const oauth = publicAccess ? oauthProviders() : [];
586
+ const signInProvider = oauth.length ? "oauth" : access ? "cloudflare" : "email";
587
+ const signInOptions = [...oauth.map((provider) => ({ kind: provider.name, label: `Continue with ${provider.label}` })), ...(access ? [{ kind: "cloudflare", label: "Continue with a one-time code" }] : []), { kind: "email", label: "Email me a link" }];
580
588
  const openAccountSession = (response, signedIn, location = "/?signin=done") => {
581
589
  logUsage("signin.done", { account: signedIn.account.id.slice(0, 8), provider: signInProvider });
582
590
  response.writeHead(303, { location, "set-cookie": `${ACCOUNT_COOKIE}=${encodeURIComponent(signedIn.session)}; HttpOnly; SameSite=Lax;${secureCookies ? " Secure;" : ""} Path=/; Max-Age=7776000` });
@@ -865,6 +873,44 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
865
873
  json(response, 200, { ok: true, sent: true });
866
874
  return;
867
875
  }
876
+ // "Continue with Google" — leg one: send them to the provider with a one-time state that
877
+ // comes back in a cookie, so a callback can only land in the browser that started it.
878
+ const oauthStartMatch = publicAccess && request.method === "GET" ? url.pathname.match(/^\/auth\/([a-z]{2,20})$/) : null;
879
+ if (oauthStartMatch && isOauthProvider(oauthStartMatch[1])) {
880
+ const provider = oauthStartMatch[1];
881
+ let authorize;
882
+ const state = crypto.randomBytes(16).toString("hex");
883
+ try { authorize = oauthAuthorizeUrl({ provider, origin: publicOrigins[0], state }); }
884
+ catch (error) { response.writeHead(404, { "content-type": "text/plain; charset=utf-8" }); response.end(error.message); return; }
885
+ response.writeHead(303, { location: authorize, "set-cookie": `${OAUTH_STATE_COOKIE}=${state}; HttpOnly; SameSite=Lax;${secureCookies ? " Secure;" : ""} Path=/auth; Max-Age=600` });
886
+ response.end();
887
+ return;
888
+ }
889
+ // Leg two: the provider sends them back. Trade the code for a verified address, open the
890
+ // session, and drop the token.
891
+ const oauthBackMatch = publicAccess && request.method === "GET" ? url.pathname.match(/^\/auth\/([a-z]{2,20})\/callback$/) : null;
892
+ if (oauthBackMatch && isOauthProvider(oauthBackMatch[1])) {
893
+ const provider = oauthBackMatch[1];
894
+ const expected = cookies(request)[OAUTH_STATE_COOKIE] || "";
895
+ const clear = `${OAUTH_STATE_COOKIE}=; HttpOnly; SameSite=Lax;${secureCookies ? " Secure;" : ""} Path=/auth; Max-Age=0`;
896
+ const refuse = (why) => {
897
+ logUsage("signin.oauth.refused", { provider, reason: why });
898
+ response.writeHead(303, { location: "/?signin=failed", "set-cookie": clear });
899
+ response.end();
900
+ };
901
+ if (!url.searchParams.get("code") || !expected || url.searchParams.get("state") !== expected) { refuse("state"); return; }
902
+ try {
903
+ const email = await (oauthExchange || oauthEmailFromCode)({ provider, origin: publicOrigins[0], code: url.searchParams.get("code") });
904
+ const signedIn = accounts.signIn(email);
905
+ logUsage("signin.done", { account: signedIn.account.id.slice(0, 8), provider });
906
+ response.writeHead(303, {
907
+ location: "/?signin=done",
908
+ "set-cookie": [clear, `${ACCOUNT_COOKIE}=${encodeURIComponent(signedIn.session)}; HttpOnly; SameSite=Lax;${secureCookies ? " Secure;" : ""} Path=/; Max-Age=7776000`],
909
+ });
910
+ response.end();
911
+ } catch (error) { refuse(String(error.message || error).slice(0, 80)); }
912
+ return;
913
+ }
868
914
  const authLinkMatch = publicAccess && request.method === "GET" ? url.pathname.match(/^\/auth\/([A-Za-z0-9_-]{20,})$/) : null;
869
915
  if (authLinkMatch) {
870
916
  const signedIn = accounts.redeem(authLinkMatch[1]);
@@ -1035,7 +1081,7 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
1035
1081
  json(response, 200, {
1036
1082
  csrfToken, mode: "public", product: "Tapp", root: null, repository: null, repositories: [],
1037
1083
  contract: customerProductContract, supportedPlatforms: ["web"], runners: [],
1038
- access: "account", email: account.email, signInProvider, viaToken,
1084
+ access: "account", email: account.email, signInProvider, signInOptions, viaToken,
1039
1085
  accepts: ["url"],
1040
1086
  selfHostOnly: ["path", "github", "bundle", "app", "apk"],
1041
1087
  });
@@ -1045,7 +1091,7 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
1045
1091
  json(response, 200, {
1046
1092
  csrfToken, mode: "public", product: "Tapp", root: null, repository: null, repositories: [],
1047
1093
  contract: customerProductContract, supportedPlatforms: ["web"], runners: [],
1048
- access: "anonymous", signInProvider,
1094
+ access: "anonymous", signInProvider, signInOptions,
1049
1095
  // The prompt screen offers folders, bundle ids and builds. None of them can work in
1050
1096
  // a hosted Studio — there is no Mac, no simulator and no access to the visitor's
1051
1097
  // disk — so say so here rather than letting the UI offer them.
@@ -0,0 +1,103 @@
1
+ // "Continue with Google" — signing in on our own page, without tapp sending a single email.
2
+ //
3
+ // Two providers, both plain OAuth 2.0 authorization-code flows, both reduced to the one thing a
4
+ // tapp account is: a verified email address. No profile, no avatar, no scope beyond that, and no
5
+ // token kept after the exchange — the address is traded for a tapp session and everything else
6
+ // is dropped on the floor.
7
+ //
8
+ // Configured by environment, so a Studio that has no client id simply does not offer the button:
9
+ // TAPP_OAUTH_GOOGLE_CLIENT_ID / TAPP_OAUTH_GOOGLE_CLIENT_SECRET
10
+ // TAPP_OAUTH_GITHUB_CLIENT_ID / TAPP_OAUTH_GITHUB_CLIENT_SECRET
11
+ //
12
+ // The redirect URI is always <origin>/auth/<provider>/callback, which is what you register with
13
+ // the provider. Nothing here is ever logged: a client secret, a code and an access token all
14
+ // appear only as arguments to fetch.
15
+ const PROVIDERS = {
16
+ google: {
17
+ label: "Google",
18
+ authorizeUrl: "https://accounts.google.com/o/oauth2/v2/auth",
19
+ tokenUrl: "https://oauth2.googleapis.com/token",
20
+ scope: "openid email",
21
+ // `select_account` so a shared machine does not silently sign in as whoever was last here.
22
+ extraAuthorizeParams: { prompt: "select_account", access_type: "online" },
23
+ async email(accessToken, fetchImpl) {
24
+ const response = await fetchImpl("https://openidconnect.googleapis.com/v1/userinfo", { headers: { authorization: `Bearer ${accessToken}` } });
25
+ if (!response.ok) throw new Error(`Google would not say who signed in (${response.status})`);
26
+ const profile = await response.json();
27
+ // An unverified address would let anyone claim anyone's account.
28
+ if (!profile.email || profile.email_verified === false) throw new Error("That Google account has no verified email address.");
29
+ return String(profile.email);
30
+ },
31
+ },
32
+ github: {
33
+ label: "GitHub",
34
+ authorizeUrl: "https://github.com/login/oauth/authorize",
35
+ tokenUrl: "https://github.com/login/oauth/access_token",
36
+ scope: "user:email",
37
+ extraAuthorizeParams: {},
38
+ async email(accessToken, fetchImpl) {
39
+ const response = await fetchImpl("https://api.github.com/user/emails", {
40
+ headers: { authorization: `Bearer ${accessToken}`, accept: "application/vnd.github+json", "user-agent": "tapp" },
41
+ });
42
+ if (!response.ok) throw new Error(`GitHub would not say who signed in (${response.status})`);
43
+ const addresses = await response.json();
44
+ const chosen = (Array.isArray(addresses) ? addresses : []).find((a) => a.primary && a.verified) || (Array.isArray(addresses) ? addresses : []).find((a) => a.verified);
45
+ if (!chosen?.email) throw new Error("That GitHub account has no verified email address.");
46
+ return String(chosen.email);
47
+ },
48
+ },
49
+ };
50
+
51
+ /** Which providers this deployment can actually offer, in the order they should be shown. */
52
+ export function oauthProviders(env = process.env) {
53
+ return Object.entries(PROVIDERS)
54
+ .filter(([name]) => (env[`TAPP_OAUTH_${name.toUpperCase()}_CLIENT_ID`] || "").trim() && (env[`TAPP_OAUTH_${name.toUpperCase()}_CLIENT_SECRET`] || "").trim())
55
+ .map(([name, provider]) => ({ name, label: provider.label }));
56
+ }
57
+
58
+ export function isOauthProvider(name) {
59
+ return Object.prototype.hasOwnProperty.call(PROVIDERS, String(name));
60
+ }
61
+
62
+ export function oauthRedirectUri(origin, name) {
63
+ return `${String(origin).replace(/\/$/, "")}/auth/${name}/callback`;
64
+ }
65
+
66
+ /** Where to send someone who pressed "Continue with Google". */
67
+ export function oauthAuthorizeUrl({ provider, origin, state, env = process.env }) {
68
+ const definition = PROVIDERS[provider];
69
+ if (!definition) throw new Error(`Unknown sign-in provider '${provider}'`);
70
+ const clientId = (env[`TAPP_OAUTH_${provider.toUpperCase()}_CLIENT_ID`] || "").trim();
71
+ if (!clientId) throw new Error(`${definition.label} sign-in is not configured here`);
72
+ const url = new URL(definition.authorizeUrl);
73
+ url.searchParams.set("client_id", clientId);
74
+ url.searchParams.set("redirect_uri", oauthRedirectUri(origin, provider));
75
+ url.searchParams.set("response_type", "code");
76
+ url.searchParams.set("scope", definition.scope);
77
+ url.searchParams.set("state", state);
78
+ for (const [key, value] of Object.entries(definition.extraAuthorizeParams)) url.searchParams.set(key, value);
79
+ return url.href;
80
+ }
81
+
82
+ /**
83
+ * Trade the code the provider sent back for the one thing we want: a verified email address.
84
+ * The access token is used once, here, and never stored.
85
+ */
86
+ export async function oauthEmailFromCode({ provider, origin, code, env = process.env, fetchImpl = fetch }) {
87
+ const definition = PROVIDERS[provider];
88
+ if (!definition) throw new Error(`Unknown sign-in provider '${provider}'`);
89
+ const clientId = (env[`TAPP_OAUTH_${provider.toUpperCase()}_CLIENT_ID`] || "").trim();
90
+ const clientSecret = (env[`TAPP_OAUTH_${provider.toUpperCase()}_CLIENT_SECRET`] || "").trim();
91
+ if (!clientId || !clientSecret) throw new Error(`${definition.label} sign-in is not configured here`);
92
+ const response = await fetchImpl(definition.tokenUrl, {
93
+ method: "POST",
94
+ headers: { "content-type": "application/x-www-form-urlencoded", accept: "application/json", "user-agent": "tapp" },
95
+ body: new URLSearchParams({ client_id: clientId, client_secret: clientSecret, code, redirect_uri: oauthRedirectUri(origin, provider), grant_type: "authorization_code" }).toString(),
96
+ });
97
+ if (!response.ok) throw new Error(`${definition.label} refused the sign-in (${response.status})`);
98
+ const token = await response.json();
99
+ // The provider's own error field, which arrives with a 200 on GitHub.
100
+ if (token.error) throw new Error(`${definition.label} refused the sign-in`);
101
+ if (!token.access_token) throw new Error(`${definition.label} returned no access token`);
102
+ return definition.email(token.access_token, fetchImpl);
103
+ }
@@ -15,7 +15,7 @@ import { createRequire } from "module";
15
15
  import {
16
16
  NAV_TIMEOUT_MS, loadPlaywright, webBrowserLaunchOptions, webContextOptions, installWebListenerTracking,
17
17
  waitForWebStability, captureElementEvidence, shouldReportWebRequestFailure, auditStructuralControls,
18
- auditFindingsFromControls, slug,
18
+ auditFindingsFromControls, slug, detectBlockingOverlay, chooseOverlayDismissal,
19
19
  } from "./web-explorer.js";
20
20
  import { buildQaReport } from "./report.js";
21
21
  import { collectPageObservations, observationFindings, OBSERVATION_SCOPE } from "./page-observations.js";
@@ -258,6 +258,18 @@ async function auditOnePage(context, target, { timeoutMs, linkCheckLimit, captur
258
258
  // Things a person would notice and not like — counted and listed apart from defects, so the
259
259
  // issue count never quietly includes opinions. See page-observations.js.
260
260
  const observations = observationFindings(await collectPageObservations(page));
261
+ // A pop-up in front of the page is the first thing a visitor meets, and the read-only pass
262
+ // cannot press it — that is the promise. So say it is there, name it, and name the way out
263
+ // it offers, rather than quietly judging a page that was never visible.
264
+ const overlay = await detectBlockingOverlay(page).catch(() => null);
265
+ if (overlay) {
266
+ const wayOut = chooseOverlayDismissal(overlay.buttons);
267
+ observations.push({
268
+ category: "polish", severity: "medium", type: "blocking_overlay",
269
+ title: `A pop-up covers the page${overlay.heading ? `: “${overlay.heading}”` : ""} — nothing was clicked, so what it covers was not seen${wayOut ? ` (its way out is “${wayOut}”)` : ""}`,
270
+ target: overlay.heading || overlay.buttons[0] || "overlay",
271
+ });
272
+ }
261
273
  const screen = target.pathname + target.search;
262
274
  for (const f of [...findings, ...observations]) { f.screen = screen; if (!f.url) f.url = page.url(); }
263
275
 
@@ -300,6 +312,7 @@ async function auditOnePage(context, target, { timeoutMs, linkCheckLimit, captur
300
312
  // Why the wiring-dependent checks were skipped on this page, if they were.
301
313
  ...(controls.wiringUnverifiable ? { wiringUnverifiable: controls.wiringUnverifiable } : {}),
302
314
  findings,
315
+ ...(overlay ? { blockedByOverlay: true } : {}),
303
316
  ...(statePath ? { screenshot: statePath } : {}),
304
317
  ...(framePath ? { frame: framePath } : {}),
305
318
  links: allowedLinks,
@@ -498,6 +511,7 @@ export async function auditWebSite({
498
511
  await context.close();
499
512
  const findings = results.flatMap((r) => r.findings);
500
513
  const observations = dedupeSiteIssues(results.flatMap((r) => r.observations || []));
514
+ const coveredPages = results.filter((r) => r.blockedByOverlay).length;
501
515
  const issues = dedupeSiteIssues(findings);
502
516
  const bySeverity = { critical: 0, high: 0, medium: 0, low: 0 };
503
517
  for (const f of findings) if (f.severity in bySeverity) bySeverity[f.severity] += 1;
@@ -526,7 +540,12 @@ export async function auditWebSite({
526
540
  observationCount: observations.length,
527
541
  lookedForAlso: OBSERVATION_SCOPE,
528
542
  checkedFor: scope.checkedFor,
529
- notChecked: [...scope.notChecked, ...observationLimits, ...(skippedLinks.size ? ["Potential action/signed links and robots exclusions were not fetched; see skippedLinks."] : [])],
543
+ notChecked: [
544
+ ...scope.notChecked,
545
+ ...(coveredPages ? [`whatever a pop-up covered on ${coveredPages} page(s) — a read-only pass never presses anything, so it was not seen (sign in and tapp gets past it and clicks)`] : []),
546
+ ...observationLimits,
547
+ ...(skippedLinks.size ? ["Potential action/signed links and robots exclusions were not fetched; see skippedLinks."] : []),
548
+ ],
530
549
  pages: results,
531
550
  capture: null,
532
551
  };
@@ -430,7 +430,13 @@ export function chooseOverlayDismissal(labels = []) {
430
430
  * undiscovered. Escape closes a well-built dialog and nothing else, so find the dismissal the
431
431
  * overlay itself offers.
432
432
  */
433
- export async function dismissBlockingOverlay(page) {
433
+ /**
434
+ * Find what is standing in front of the page, without touching it.
435
+ *
436
+ * The read-only audit must not press anything — that is the whole promise — but it can still say
437
+ * a pop-up is there, name it, and name the way out it offers. A visitor meets that pop-up too.
438
+ */
439
+ export async function detectBlockingOverlay(page) {
434
440
  // Overlays come in shapes, not one shape. A measured probe of the common ones found that a
435
441
  // size-and-position rule written for a big centred modal misses a native <dialog> (absolute by
436
442
  // default), a small bottom sheet, a short cookie bar and a corner toast — four of the five
@@ -477,7 +483,13 @@ export async function dismissBlockingOverlay(page) {
477
483
  const heading = (chosen.element.querySelector("h1,h2,h3,h4,p,span")?.innerText || "").replace(/\s+/g, " ").trim().slice(0, 90);
478
484
  return { buttons: chosen.buttons, heading };
479
485
  }, undefined, { timeout: 2_000 }).catch(() => null);
480
- if (!found?.buttons?.length) return null;
486
+ return found?.buttons?.length ? found : null;
487
+ }
488
+
489
+ /** Find it, then press its own way out — never a way out that grants something. */
490
+ export async function dismissBlockingOverlay(page) {
491
+ const found = await detectBlockingOverlay(page);
492
+ if (!found) return null;
481
493
  const label = chooseOverlayDismissal(found.buttons);
482
494
  if (!label) return null;
483
495
  const overlay = page.locator('[data-tapp-overlay="1"]');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aarwitz/tapp",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "mcpName": "io.github.aarwitz/tapp",
5
5
  "description": "Let coding agents verify UI changes on real iOS, Android, and web surfaces, then enforce reviewed proof in deterministic CI.",
6
6
  "license": "MIT",
@@ -96,7 +96,7 @@
96
96
  "mobile"
97
97
  ],
98
98
  "scripts": {
99
- "test": "node --test tests/report.test.js tests/regression.test.js tests/engine.test.js tests/project-config.test.js tests/application-model.test.js tests/ui-map.test.js tests/focused-navigation.test.js tests/task-runtime.test.js tests/release-contract.test.js tests/pr-selection.test.js tests/flow-runtime.test.js tests/web-explorer.test.js tests/web-session.test.js tests/web-link-audit.test.js tests/web-overlay.test.js tests/web-audit.test.js tests/page-observations.test.js tests/capture-provenance.test.js tests/capture-frames.test.js tests/actor-store.test.js tests/account-store.test.js tests/access-jwt.test.js tests/studio-client.test.js tests/journeys.test.js tests/ios-crash-attribution.test.js tests/ios-simulator-selection.test.js tests/ios-recording-stop.test.js tests/web-flow.test.js tests/scenario-runtime.test.js tests/android-driver.test.js tests/android-explorer.test.js tests/android-flow.test.js tests/android-primitives-protocol.test.js tests/managed-web.test.js tests/product-operations.test.js tests/job-lanes.test.js tests/browser-product.test.js tests/browser-chat-narration.test.js tests/browser-onboarding.test.js tests/managed-operation.test.js tests/ci-setup.test.js tests/ci-install.test.js tests/cli.test.js tests/mcp-workspace.test.js tests/action.test.js tests/package-surface.test.js tests/agent-surface.test.js tests/presentation-contract.test.js tests/landing-brand.test.js tests/ci-gate.test.js tests/ci-report.test.js tests/desktop-protocol.test.js tests/ios-flow-protocol.test.js tests/feedback-triage-0919.test.js vscode-extension/test/bridge.test.js",
99
+ "test": "node --test tests/report.test.js tests/regression.test.js tests/engine.test.js tests/project-config.test.js tests/application-model.test.js tests/ui-map.test.js tests/focused-navigation.test.js tests/task-runtime.test.js tests/release-contract.test.js tests/pr-selection.test.js tests/flow-runtime.test.js tests/web-explorer.test.js tests/web-session.test.js tests/web-link-audit.test.js tests/web-overlay.test.js tests/web-audit.test.js tests/page-observations.test.js tests/capture-provenance.test.js tests/capture-frames.test.js tests/actor-store.test.js tests/account-store.test.js tests/access-jwt.test.js tests/oauth.test.js tests/studio-client.test.js tests/journeys.test.js tests/ios-crash-attribution.test.js tests/ios-simulator-selection.test.js tests/ios-recording-stop.test.js tests/web-flow.test.js tests/scenario-runtime.test.js tests/android-driver.test.js tests/android-explorer.test.js tests/android-flow.test.js tests/android-primitives-protocol.test.js tests/managed-web.test.js tests/product-operations.test.js tests/job-lanes.test.js tests/browser-product.test.js tests/browser-chat-narration.test.js tests/browser-onboarding.test.js tests/managed-operation.test.js tests/ci-setup.test.js tests/ci-install.test.js tests/cli.test.js tests/mcp-workspace.test.js tests/action.test.js tests/package-surface.test.js tests/agent-surface.test.js tests/presentation-contract.test.js tests/landing-brand.test.js tests/ci-gate.test.js tests/ci-report.test.js tests/desktop-protocol.test.js tests/ios-flow-protocol.test.js tests/feedback-triage-0919.test.js vscode-extension/test/bridge.test.js",
100
100
  "test:browser-journey": "node --test tests/browser-journey.test.js",
101
101
  "test:browser-native": "TAPP_RUN_NATIVE_BROWSER=1 node --test tests/browser-native-journey.test.js"
102
102
  }