@synqauth/js
v0.3.0
Published
Synq's framework-agnostic client: sign-in and sessions in the browser, the account API, and token and webhook verification on your server.
Readme
@synqauth/js
Synq's framework-agnostic client: sign-in and sessions in the browser, the account API, and token and webhook verification on your server.
Synq is customer identity for businesses: an OpenID Connect issuer for each of your brands, with Solana wallet, social, email and passkey sign-in. The documentation is at docs.synq.build.
This package is at 0.x, so a minor release can change its API: see its CHANGELOG.md.
The account API
For an app that holds its own session, createAccountClient calls the brand's account API for the person signed in:
import { accountApiUrl, createAccountClient, createSynqClient, linkSignIn } from '@synqauth/js'
const synq = createSynqClient({
issuer: 'https://acme.auth.synq.build',
clientId: 'app_…',
redirectUri: 'https://app.example.com/callback',
scope: 'openid offline_access me:read me:write',
resource: accountApiUrl('https://acme.auth.synq.build'),
})
const account = createAccountClient({
issuer: 'https://acme.auth.synq.build',
accessToken: () => synq.getAccessToken(),
})
const { data: me, error } = await account.me()
await account.user.update({ name: 'Ada Lovelace' })
// Adding a wallet: a link request, then a fresh sign-in that carries it.
const { data: request } = await account.accounts.link('wallet')
if (request) await synq.signIn(linkSignIn(request))accounts.link() takes any method accounts.linkable() lists. For passkey it answers the hosted add-passkey sign-in instead of a link request, sent the same way with linkSignIn.
Every call answers { data, error } and never throws for what Synq answers; branch on error.code.
License
MIT
Synq customer email work
solveEmailWork(challenge, { signal }) is a public bounded solver for the self-hosted email-work protocol, in plain JavaScript: it needs no WebCrypto and yields between short slices of work. Current own-UI email sends solve and retry at most once when Synq’s customer brand requires it. flow.cancelEmailWork() cancels local computation; newer operations invalidate older work. It does not enable work on tenant brands or prove authentication. See the own-UI protocol guide. Runtime activation remains staged until migration, SDK and browser performance validation.
