API
createSigport
ts
import { createSigport } from '@sigport/core';
const sigport = createSigport(options);| Option | Type | Default |
|---|---|---|
adapters | Adapter[] | required. all() gives every built-in one |
include | string[] | keep only these ids |
exclude | string[] | drop these ids |
app | { name, url?, image? } | { name: 'sigport', url: location.origin } |
storage | StorageLike | null | localStorage; null remembers nothing |
namespace | string | 'sigport', so accounts are kept at sigport:accounts:v1 |
messages | Record<code, string> | error sentences to override |
plan | (detected) => Plan | planSignIn |
scope | PageScope | globalThis |
waitMs | number | 300: how long wallets get to announce themselves |
onSignIn | (account) => void | |
onSignOut | () => void |
Nothing touches the page until detect() runs, so a session is safe to create during server rendering.
Session
| Member | Does |
|---|---|
getState() | The current state |
subscribe(listener) | Calls listener(state) on every change; returns the unsubscribe |
detect() | Reads the page once and plans the list; later calls return the first result |
recheck() | Reads the page again |
choose(id) | What a row does: one-click sign-in, or open the view or catalog |
openCatalog(id) | Opens an adapter's list of apps |
back() | Back to the list; stops pairing |
run(actionId, values) | Runs an action of the open view |
startPairing() | Shows the open view's pairing code and waits for the signer |
signInWith(account) | Signs in with an account made elsewhere |
resume(account) | Signs in with a remembered account, unlocking it if needed |
signOut() | Signs out; the account stays remembered |
forget(account) | Drops a remembered account |
dismissError() | Clears the error |
adapter(id), viewOf(id) | An adapter and its resolved view |
adapters, manager, app | The adapters in use, applesauce's AccountManager, the app info |
destroy() | Stops listening |
State
| Field | Type |
|---|---|
status | 'idle' | 'detecting' | 'ready' |
plan | { shown: PlannedOption[], others: PlannedOption[] } | null |
availability | Record<id, 'ready' | 'missing' | 'outdated' | 'unsupported'> |
installed | Record<id, string[]>: catalog apps found in the page |
screen | { name: 'list' } | { name: 'view', adapter } | { name: 'catalog', adapter } | { name: 'unlock', adapter, account } |
pairing | { uri } | null |
busy | boolean |
error | string | null, in plain words |
accounts | remembered IAccount[], throwaways excluded |
active | IAccount | null |
all
ts
import { all, BUILT_IN_IDS } from '@sigport/core/all';
all({ include?, exclude?, extension?, remote?, metamask?, passkey?, local?, guest? });Returns the built-in adapters in kernl's order (extension, remote, metamask, onekey, okx, passkey, local, readonly, guest), each with its options.
defineAdapter
Returns the adapter you give it, typed. See Writing an adapter.
planSignIn
ts
planSignIn(detected: { id, kind, availability, links? }[]): { shown, others }The ranking, as a pure function.
Presentation helpers
| Helper | Returns |
|---|---|
describeRows(sigport, state) | { shown: Row[], others: Row[] } ready to draw |
describeRow(sigport, option, state) | One Row |
describeCatalog(sigport, id, state) | An adapter's apps, installed ones first |
describeAccount(account) | { name, via } |
describeError(reason, messages?) | A sentence |
Accounts
| Export | |
|---|---|
createAccounts({ storage, namespace, types }) | applesauce AccountManager, restored and saved |
SafeAccountManager | refuses nsec and seed-words accounts |
PLAINTEXT_KEY_ACCOUNT_TYPES | ['nsec', 'seed-words'] |
checkedWalletKey, checkedWalletEvent | verify what a wallet returns |
WalletProviderSigner | a signer over any NIP-07-shaped provider |
Elements
Export from @sigport/elements | |
|---|---|
SigportSignIn | the panel class (registers nothing) |
SigportButton | the button-and-dialog class |
DEFAULT_STRINGS | every word the panel shows |
graphite | the stylesheet |
@sigport/elements/define registers <sigport-signin> and <sigport-button> with every built-in adapter.
Attributes: app-name, include, exclude, snap-id, relays, namespace, theme, bare, hide-footer. Properties: sigport, strings. Events: sigport-signin (detail.account), sigport-signout.