Awesome Reviewers

Security decisions (sandboxing, allow/deny access, and token attachment) must remain correct across time, async races, and concurrent policy contributions.

Apply this standard: 1) Re-evaluate enablement per execution

2) Preserve policy provenance and enforce deny-wins

3) Prevent TOCTOU with cancellation/epochs

4) Cancel in-flight UI-triggered security operations on revocation

5) Never leak credentials/bearer tokens

6) Clear security markers per interaction

Minimal example pattern (epoch + cancellation + safe token target):

const ctsRef = new MutableDisposable();
let epoch = 0;

async function resolveAccess(nowUrl: string) {
  const token = (ctsRef.value = new CancellationTokenSource()).token;
  const myEpoch = ++epoch;

  // 1) start async eligibility check, pass token so it can abort
  const result = await eligibilityRequest({ url: nowUrl, cancellationToken: token });
  if (token.isCancellationRequested || myEpoch !== epoch) return; // TOCTOU guard

  // 2) only now mutate shared state
  if (result.eligible) updateManifest();
  else markDenied();
}

function authorizationHeader(targetUrl: string): Record<string, string> {
  if (!isSameSecureOrigin(targetUrl, marketplaceEligibilityOrigin)) return {};
  return { Authorization: `Bearer ${token}` };
}