auth
import auth from "fullstacked/auth";A small helper for popup sign-in flows: it opens a page in a popup and resolves with the message that page posts back.
authenticate(url: string, opts?: { windowFeatures?: string }): Promise<any>auth=1is added tourl's query, so the sign-in page knows it runs in a FullStacked popup.urlis opened withwindow.open, centered at 500×600 unlesswindowFeaturesis given.- The promise resolves with the
dataof the firstmessageevent the window receives. If thatdatais anError, it rejects instead.
The sign-in page ends the flow with window.opener.postMessage(result, "*"). Pick a target origin that fits your flow.
const session = await auth.authenticate("https://accounts.example.com/sign-in");In the native apps
Identity providers refuse sign-in inside embedded webviews, so the apps open the page in the system browser instead of a popup: ASWebAuthenticationSession on iOS and macOS, Custom Tabs on Android, the default browser on Windows. They add native=1 and callback_scheme=fullstacked-auth to the query. The sign-in page then ends the flow by redirecting to fullstacked-auth://auth?<result as query parameters>, and the app delivers those parameters, as an object, as the message the promise resolves with. There is no window.opener in this mode.
Inside the runtime, closing the popup without posting doesn't reject the promise. The closed-window check only runs outside FullStacked. Give your UI a way to cancel.
The module only uses window, so it is for pages, not workers or --file scripts.