Skip to content

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 prompts

Bind its state ​

StackBinding
ReactuseSigport(sigport)
VueuseSigport(sigport), a shallow ref
SveltesigportStore(sigport), then $state
SoliduseSigport(sigport), an accessor
Anythingsigport.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:

FieldMeaning
label, noteTitle and subtitle
icon / logo24×24 stroke paths, or an image URL
emphasistop, likely or quiet: how strongly to draw it
enabledWhether clicking does anything
opensIt slides to another view: draw a chevron
dashedA throwaway: draw it dashed
sideThe 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 }. Draw sigport.viewOf(adapter). Its fields are inputs and its actions are buttons that call sigport.run(action.id, values). With view.pairing, a button calls sigport.startPairing(), and state.pairing.uri is the code to render as a QR.
  • { name: 'catalog', adapter }. Draw describeCatalog(sigport, adapter, state): apps with name, platforms, href, link, installed.
  • { name: 'unlock', adapter, account }. A remembered account needs a password. Draw sigport.adapter(adapter).unlock.view(account).

sigport.back() returns to the list from any of them.

Remembered and active accounts ​

  • state.accounts lists 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.active is 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, run and resume from click handlers. Browsers only show a passkey prompt in response to the person's own action.
  • Show state.error in a role="alert" region. It is already in plain words.

MIT licensed.