Setup
adapter— connects to the auth backend (passwordless start/verify, social authenticate, refresh token).router— a minimal router withpush/replaceso the service can redirect post-login.shop—{ domain, locale };localecan be aSignal<string>so login adopts the current theme locale.
Shape
Example: passwordless start
Token management
getToken() returns the current access token, refreshing it transparently if it has expired (using the stored refresh token). Wire it into the fetch layer to ensure all API requests include a valid access token: