Browser widget

One script tag that shows:

<script src="https://trowyn.com/sdk/trowyn-widget-0.1.0.js"
        integrity="sha384-CfY4ZxUEeNCEPHsnkVqcwdZBlvRS+nmm+Jzz4gu6yjb0WwBAK8cpoTlTGvjb/9dD"
        crossorigin="anonymous" defer></script>

https://trowyn.com/sdk/trowyn-widget.js is always the latest version (no SRI). The file is also in the npm tarball @trowyn/widget if you'd rather host it yourself.

Approval mode

Your server calls create-approval and returns id, client_token, match_number and expires_at to the page. Never the API key.

TrowynWidget.mount("#trowyn", {
  mode: "approval",
  approvalId: a.id,
  clientToken: a.client_token,
  matchNumber: a.match_number,
  expiresAt: a.expires_at,
  onComplete(d) {
    if (d.status === "approved") fetch("/login/trowyn/complete", { method: "POST" }); // your server checks
  },
  onRetry() { location.reload(); },
});
TrowynWidget.mount("#trowyn", {
  mode: "link",
  linkCodeId: link.id, clientToken: link.client_token,
  linkUrl: link.link_url, code: link.code, expiresAt: link.expires_at,
  onComplete(d) { if (d.status === "linked") location.reload(); },
});

Without JavaScript of your own

<div data-trowyn-widget data-mode="approval"
     data-approval-id="…" data-client-token="…" data-match-number="37" data-expires-at="…"></div>

Link mode uses data-link-code-id, data-client-token, data-link-url, data-code, data-expires-at. Every change fires a bubbling trowyn:status event: document.addEventListener("trowyn:status", (e) => e.detail).

Reference

Option
mode "approval" (default) or "link"
approvalId / linkCodeId, clientToken From your server's create call. Required
matchNumber, expiresAt, linkUrl, code Shown in the panel
title Heading override
environment "test" shows a TEST MODE badge
onStatus(detail), onComplete(detail), onRetry(status) detail = { mode, id, status, reason }
pollIntervalMs Default 2000. Backs off on network errors; checks again as soon as the tab is visible

mount() returns { destroy(), status }. Statuses: pending, approved, denied, expired, linked, and error (unknown token or the network kept failing).

Theming: set --trowyn-accent, --trowyn-bg, --trowyn-fg, --trowyn-border, --trowyn-radius on the container, or style ::part(card). It follows the system's dark mode.

Content Security Policy: no inline scripts or styles, no eval, no data: URLs (the QR is SVG). Add https://trowyn.com to script-src and https://xkxmnvnxorhwlvgcihhy.supabase.co to connect-src.

It's only a display. The widget reads client-status, which anyone holding the token could read. Your server must confirm the result with approval-status (or a webhook) for the approval it created for this sign-in before letting the user in.