Validate an authenticated session and run a credential fallback when the profile is not signed in.
librettoAuthenticate()
librettoAuthenticate is the runtime helper for workflows that combine an auth profile with a scripted login fallback.
Options
Checks whether the current browser page is signed in. Return
true only when
the workflow can safely continue.fallback
(ctx: LibrettoWorkflowContext, credentials: Record<string, string>) => Promise<void> | void
required
Performs the login flow when
validate returns false.Credential values to pass to the fallback. In workflows, pass
input.credentials from declared workflow credentials.Optional environment variable prefix used only when
credentials is omitted.
Workflow code should normally pass input.credentials instead.Return value
true when the initial validation passed, meaning the saved profile was
already signed in. false when Libretto ran the fallback login.Example
fallback runs, librettoAuthenticate calls validate again. If validation still fails, it throws an error instead of letting the workflow continue in a logged-out state.
Pair
librettoAuthenticate with authProfile: { name, refresh: true } when
successful fallback login should update the profile for future runs.