Your own UI
The panel is one way to draw sigport. Underneath is createSigport(), a framework-free store with sigport's detection, ranking, adapters and account handling. Bind it to your framework and draw whatever markup you like.
Make a session
ts
import { createSigport } from '@sigport/core';
import { all } from '@sigport/core/all';
const sigport = createSigport({ adapters: all(), app: { name: 'My app' } });
await sigport.detect(); // reads the page once, never promptsBind its state
| Stack | Binding |
|---|---|
| React | useSigport(sigport) |
| Vue | useSigport(sigport), a shallow ref |
| Svelte | sigportStore(sigport), then $state |
| Solid | useSigport(sigport), an accessor |
| Anything | sigport.subscribe(render) and sigport.getState() |
Draw the list
describeRows turns the plan into rows that are ready to draw:
ts
import { describeRows } from '@sigport/core';
const { shown, others } = describeRows(sigport, state);Each row has:
| Field | Meaning |
|---|---|
label, note | Title and subtitle |
icon / logo | 24×24 stroke paths, or an image URL |
emphasis | top, likely or quiet: how strongly to draw it |
enabled | Whether clicking does anything |
opens | It slides to another view: draw a chevron |
dashed | A throwaway: draw it dashed |
side | The square on the right: { kind: 'catalog' }, or a link { kind: 'info' | 'download' | 'open', href } |
Wire the clicks to the store:
ts
row.onclick = () => sigport.choose(id); // sign in, or open its view or catalog
square.onclick = () => sigport.openCatalog(id); // when side.kind === 'catalog'Here is a small React version:
tsx
function Picker({ sigport }) {
const state = useSigport(sigport);
const { shown } = describeRows(sigport, state);
if (state.status !== 'ready') return <p>Looking for ways to sign in…</p>;
return (
<ul>
{shown.map((row) => (
<li key={row.id}>
<button disabled={!row.enabled || state.busy} onClick={() => sigport.choose(row.id)}>
<strong>{row.label}</strong> <small>{row.note}</small>
</button>
</li>
))}
{state.error && <li role="alert">{state.error}</li>}
</ul>
);
}The other screens
state.screen says what to show:
{ name: 'list' }. The list above.{ name: 'view', adapter }. Drawsigport.viewOf(adapter). Itsfieldsare inputs and itsactionsare buttons that callsigport.run(action.id, values). Withview.pairing, a button callssigport.startPairing(), andstate.pairing.uriis the code to render as a QR.{ name: 'catalog', adapter }. DrawdescribeCatalog(sigport, adapter, state): apps withname,platforms,href,link,installed.{ name: 'unlock', adapter, account }. A remembered account needs a password. Drawsigport.adapter(adapter).unlock.view(account).
sigport.back() returns to the list from any of them.
Remembered and active accounts
state.accountslists remembered accounts.describeAccount(account)gives{ name, via }.sigport.resume(account)signs in with one, unlocking it first if it needs a passkey or a password.sigport.forget(account)drops it.state.activeis the signed-in account.sigport.signOut()signs out.
Lower still
planSignIn(detected) is a pure function from availability to rows. Adapters are plain objects with detect(), connect() and view. You can use them with no store at all.
Keep these
- Detect before you draw the list, so rows never move under the pointer.
- Call
choose,runandresumefrom click handlers. Browsers only show a passkey prompt in response to the person's own action. - Show
state.errorin arole="alert"region. It is already in plain words.